list - 如何将目标应用于 Ant 中的项目子列表?

标签 list ant 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>

但我必须为每个项目和每个目标集指定一个单独的子项行。我想要做的就是创建一个属性,它是一个子项目列表,并以某种方式使用它。它应该很简单,但是......

最佳答案

您可以定义一个宏来执行此操作:

<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>

关于list - 如何将目标应用于 Ant 中的项目子列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/774623/

相关文章:

java - Ant : Junit failure triggers a haltonfailure

Eclipse 中的 java.lang.NoClassDefFoundError,但 Ant 中没有

ant - 如何从生成的 JAXB 文件中删除命名空间?

python - 列表中的 x, *y 在 python 中是什么意思

python - 在 Python 中是否有一个基于值条件构建子列表的简单功能?

java - 为什么列表的 remove() 方法采用 Object 而不是 T?

c# - Visual Studio c# 相对路径,程序搜索两个路径,即使它找到了正确的路径

C 将结构体插入链表

node.js - yosemite 升级后 npm 找不到 npm-cli 模块

ruby-on-rails - 无法在 Rails 中覆盖 Devise::RegistrationsController 吗?