Intermodule dependency in ant

后端 未结 2 1486
一整个雨季
一整个雨季 2020-12-21 18:27

I am using Ant 1.8

I have multiple modules in intelliJ IDEA. Each module has a build.xml and currently i need to browse till build.xml of that file and run ant for e

相关标签:
2条回答
  • 2020-12-21 19:13

    Thanks Mark!! Your answer helped me a lot.

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

    Project Structure:


    |-- build.xml
    |-- ProjectOne
        -- build.xml
        -- antbuilds.properties
    |-- ProjectTwo
        -- build.xml
        -- antbuilds.properties

    Common ANT build file:

    <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 讨论(0)
  • 2020-12-21 19:22

    The subant task in ANT is the most flexible way to invoke a multi-module build, 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 Apache ivy. Let the ivy inter-module dependency declarations automatically determine the module build order.

    0 讨论(0)
提交回复
热议问题