I have parent project with build.xml
and subfolders containing individual modules
- build.xml
- ear-module/
- ejb-module/
- web-module/
The build.xml
calls ant for each module and then assembles them together to result ear.
This is sample from single-ant having multiple modules. I prefer to have individual ant files in each module that is called from master folder. Dependencies can be tricky in ant. This is probably the reason why people favour maven/graddle over ant.
<target name="war" depends="ejb">
<mkdir dir="${build.dir}/war" />
<path id="web-classpath">
<path refid="classpath" />
<file file="${build.dir}/${ant.project.name}.jar" />
</path>
<javac srcdir="web-module/java" classpathref="web-classpath" destdir="${build.dir}/war" debug="true"
source="${compiler.source.level}" target="${compiler.target.level}" encoding="${src.encoding}"/>
<war destfile="${build.dir}/${ant.project.name}.war" webxml="web-module/war/WEB-INF/web.xml">
<webinf dir="web-module/war/WEB-INF">
<exclude name="web.xml"/>
<exclude name="classes/**"/>
<exclude name="lib/**"/>
</webinf>
<classes dir="${build.dir}/war" />
<lib dir="web-module/war/WEB-INF/lib"/>
<fileset dir="web-module/war">
<exclude name="WEB-INF/*"/>
<exclude name="META-INF/*"/>
</fileset>
</war>
</target>