Intermodular dependence in ant

I am using Ant 1.8

I have several modules in intelliJ IDEA. Each module has build.xml and currently I need to view the build.xml file of this file and run Ant for each module. for example, the success of the assembly of module B depends on whether the assembly of module A was successful.

Now I want to update this process. It will be great if there is an option in which I can write one assembly process that first builds the distribution for module A, and then, when building the distribution for B, it checks if the assembly for module A is successful.

Is it possible to use the current Ant mechanism. I could see something similar in ivy, but I can’t use it in my project.

Please suggest an approach using the main Ant features.

+1
source share
2 answers

The subant task in ANT is the most flexible way to invoke a multi-module assembly, for example:

<project name="parent" default="build">

    <target name="build">
        <subant>
            <filelist dir=".">
                <file name="moduleA/build.xml"/>
                <file name="moduleB/build.xml"/>
            </filelist>
            <target name="clean"/>
            <target name="build"/>
        </subant>
    </target>

</project>

Project structure

|-- build.xml
|-- moduleA
|   `-- build.xml
`-- moduleB
    `-- build.xml

Note:

In my opinion, the most powerful way to use this task is to combine it with the buildlist task from the Apache plus. Let declarations of dependency between ivy modules automatically determine the assembly order of the module.

+3
source

Thank you Mark! Your answer helped me a lot.

In addition to the answer above, I would like to add details if the properties are loaded from the properties file.

Project Structure:


| - build.xml
| -     - build.xml
    - antbuilds.properties
| -     - build.xml
    - antbuilds.properties

ANT :

<project name="Parent" default="all">
<target name="ProjectOne">
    <subant>
        <property file="ProjectOne/antbuilds.properties"/>
        <filelist dir=".">
            <file name="ProjectOne/build.xml"/>
        </filelist>
        <target name="deploy"/>
    </subant>
</target>
<target name="ProjectTwo">
    <subant>
        <property file="ProjectTwo/antbuilds.properties"/>
        <filelist dir=".">
            <file name="ProjectTwo/build.xml"/>
        </filelist>
        <target name="deploy"/>
    </subant>
</target>
<target name="all" depends="ProjectOne, ProjectTwo">
</target>

0

All Articles