【问题标题】:antcall in foreach is not executing loopforeach 中的 antcall 未执行循环
【发布时间】:2013-05-20 10:50:37
【问题描述】:

我想使用 ant 脚本构建几个基于 .composites 的项目。 我在 build.xml 文件中添加了所有 taskref 标签、lib 路径。 我为此编写了以下代码,但出现错误 foreach 不支持嵌套的“antcall”元素。

<target name="createApplicationDAA">
<foreach param="program">
    <path>
        <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
    </path>
    <antcall target="createDAA"/>
</foreach>
</target>
<target name="createDAA">
..........
....
</target>

显然, 我的要求是通过在 ant 脚本中使用 foreach 或 for 循环构建所有复合材料来创建所有 DAA。 谁能告诉我,我哪里做错了?

【问题讨论】:

    标签: ant ant-contrib


    【解决方案1】:

    foreach 不使用嵌套元素来确定要运行的内容,它需要一个 target 属性:

    <target name="createApplicationDAA">
      <foreach param="program" target="createDAA">
        <path>
          <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
        </path>
      </foreach>
    </target>
    <target name="createDAA">
      <echo>${program}</echo>
    </target>
    

    或者,使用&lt;for&gt;,它采用嵌套的&lt;sequential&gt;

    <target name="createApplicationDAA">
      <for param="program">
        <path>
          <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
        </path>
        <sequential>
          <echo>@{program}</echo>
        </sequential>
      </for>
    </target>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-27
      • 2020-08-14
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2016-06-29
      • 1970-01-01
      相关资源
      最近更新 更多