I'm new to ANT. I have the below project structure,
Project
module1
build.xml
module2
build.xml
lib
What happens is, I have configured build.xml in module 2 to build a JAR of module2 classes and put it in lib folder. Now, I'm calling the build.xml fo module2 from module1's build.xml. module1 requires the module2's JAR to compile. I can see the JAR in lib folder but still module 1 is not compiling. Can some one please help me? Here my build.xml files, module1 build.xml,
<?xml version="1.0" encoding="UTF-8"?>
<property name="app.name" value="module1" />
<property name="src.home" value="${basedir}/src/main/java" />
<property name="build.home" value="${basedir}/build" />
<property name="ear.home" value="${basedir}/ear" />
<property name="module2.home" value="../module2" />
<property name="external.lib.dir" value="../lib" />
<path id="lib.path">
<fileset dir="${external.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="module2.path">
<filelist dir="${module2.home}" />
</path>
<target name="clean">
<delete dir="${build.home}" />
<delete dir="${ear.home}" />
</target>
<target name="prepare" depends ="clean"
description="Create build dirs and copy static files to work dir">
<mkdir dir="${build.home}" />
<mkdir dir="${build.home}/classes" />
</target>
<target name="compile" depends="prepare"
description="Compile Java sources and copy to build/classes dir">
<javac includeantruntime="false" srcdir="${src.home}" destdir="${build.home}/classes">
<classpath refid="lib.path" />
</javac>
<copy todir="${build.home}/classes">
<fileset dir="${src.home}" excludes="**/*.java" />
</copy>
</target>
<target name="includeJar">
<subant target="buildJar">
<fileset dir="../module2/" includes="build.xml" />
</subant>
</target>
<target name="buildEar" depends="includeJar,compile">
<jar destfile="${basedir}/ear/${app.name}.ear" basedir="${build.home}" />
</target>
And here is the module2 build.xml,
<?xml version="1.0" encoding="UTF-8"?>
<project name="module2">
<property name="app.name" value="module2"/>
<property name="src.home" value="${basedir}/src/main/java"/>
<property name="build.home" value="${basedir}/build"/>
<echo>
module2 build.xml
</echo>
<target name="clean">
<delete dir="${build.home}"/>
</target>
<target name="init" depends="clean"
description="Create build dirs and copy static files to work dir">
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}/classes"/>
</target>
<target name="compile" depends="init"
description="Compile Java sources and copy to build/classes dir">
<javac includeantruntime="false" srcdir="${src.home}"
destdir="${build.home}/classes">
</javac>
<copy todir="${build.home}/classes">
<fileset dir="${src.home}" excludes="**/*.java"/>
</copy>
</target>
<target name="buildJar" depends="compile">
<echo>Inside buildJar of module2
</echo>
<jar destfile="../lib/${app.name}.jar"
basedir="${build.home}"
/>
</target>