3

我想通过使用 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。有人可以告诉我,我在哪里做错了吗?

4

1 回答 1

4

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>

或者,使用<for>,它需要一个嵌套<sequential>

<target name="createApplicationDAA">
  <for param="program">
    <path>
      <fileset dir="${soaProjectName}/Composites" includes="**/*.composite"/>
    </path>
    <sequential>
      <echo>@{program}</echo>
    </sequential>
  </for>
</target>
于 2013-05-20T12:19:29.700 回答