3

さまざまなディレクトリに一連のサブプロジェクトがあります。それらをリストとして指定してから、特定のターゲットについて、それぞれを 1 つずつ調べて、subant を呼び出します。

私は次のようなものを持っています:

<target name="run">
    <subant target="run" failonerror="true" verbose="true">
        <fileset dir="${projectA}" includes="build.xml"/>
    </subant>
    <subant target="run" failonerror="true" verbose="true">
        <fileset dir="${projectB}" includes="build.xml"/>
    </subant>
</target>

ただし、プロジェクトごと、ターゲット セットごとに個別の subant 行を指定する必要があります。私がやりたいのは、サブプロジェクトのリストであるプロパティを作成し、それを何らかの形で使用することだけです。シンプルなはずなのに……。

4

1 に答える 1

5

これを行うマクロを定義できます。

<macrodef name="iterate-projects">
    <attribute name="target" />
    <sequential>
        <subant target="@{target}">
            <filelist dir="${src_dir}">
              <file name="projectA/build.xml"/>
              <file name="projectB/build.xml"/>
              <file name="projectC/build.xml"/>
            </filelist>
        </subant>
    </sequential>
</macrodef>

次に、別の任意のタスクから、すべてのビルドでターゲットを順番に呼び出すことができます。次に例を示します。

<target name="clean" description="Clean all projects">
   <iterate-projects target="clean"/>
</target>
于 2009-04-21T21:22:51.217 に答える