Pau*_*mer 3 ant list path fileset
我在各种目录中有一堆子项目.我想将它们指定为一个列表,然后对于给定的目标,我想逐个浏览每一个,并调用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>
Run Code Online (Sandbox Code Playgroud)
但我必须为每个项目和每个目标集指定一个单独的子行.我想做的就是创建一个子项目列表的属性,并以某种方式使用它.它应该很简单,但......
您可以定义宏来执行此操作:
<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>
Run Code Online (Sandbox Code Playgroud)
然后从另一个任务中,您可以按顺序调用所有构建的目标,例如:
<target name="clean" description="Clean all projects">
<iterate-projects target="clean"/>
</target>
Run Code Online (Sandbox Code Playgroud)