Reputation: 163
I need to build my multi module application using ant build tool, I am unable find suitable documents. I have few doubts.
Actually our application consists of 7 modules out of which 1 is EAR module(Currently we are building through eclipse without using any build tool).
So my doubt is
can i write a single build.xml i.e in EAR module(EAR project) for building project or do i need to write build.xml for every modules?
and also our project has cyclic dependencies, so is it possible to build using Ant without solving those cyclic dependencies....?
Thanks in advance
Upvotes: 0
Views: 1573
Reputation: 2734
you should have separate build.xml
s for all of your modules. build.xml
of your ear module should call all other module's build
files and finally export the ear with ear
task which may look like;
<property name="build.dir" value="/path/to/your/build-directory/" />
<property name="src.dir" value="/path/to/ear-module/" />
<target name="generate-module-jars">
<!-- this should build module and export module jar to ${build.dir} -->
<ant antfile="module1/build.xml" target="jar" />
<!-- this should build module and export module jar to ${build.dir} -->
<ant antfile="module2/build.xml" target="jar" />
<!-- this should build module and export module jar to ${build.dir} -->
<ant antfile="module3/build.xml" target="jar" />
</target>
<target name="export-ear" depends="generate-module-jars">
<ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
<fileset dir="${build.dir}" includes="*.jar,*.war"/>
</ear>
</target>
You should reorganize your modules removing cyclic dependencies. But still you can use ivy
. Or you can self implement an ant task directly calling eclipse's compiler that can handle cyclic dependencies. (if you are using eclipse)
Upvotes: 1