多个依赖于ant任务

cor*_*iKa 37 ant depends

如果我有三个目标,一个"全部",一个"编译"和一个"jsps",我将如何使"全部"取决于另外两个

可不可能是

<target name="all" depends="compile,jsps">
Run Code Online (Sandbox Code Playgroud)

还是会的?

<target name="all" depends="compile","jsps">
Run Code Online (Sandbox Code Playgroud)

或者甚至可能有什么不同?

我尝试搜索示例蚂蚁脚本以使其基础,但我找不到具有多个依赖的.

Bre*_*ail 69

前者:

<target name="all" depends="compile,jsps">
Run Code Online (Sandbox Code Playgroud)

这在Ant手册中有记录.

  • 请注意遵循这里的示例,不要在逗号后面包含空格(这会引起我的注意). (5认同)
  • @joejag我的蚂蚁在逗号后有或没有空格; 你使用的是哪个版本? (4认同)

lah*_*her 11

这是最重要的一个.

如果您想快速查看,请使用echo标签

<target name="compile"><echo>compile</echo></target>

<target name="jsps"><echo>jsps</echo></target>

<target name="all" depends="compile,jsps"></target>
Run Code Online (Sandbox Code Playgroud)

如果您想要更灵活地订购任务,还可以查看antcall标签


Don*_*oby 10

<target name="all" depends="compile,jsps">
Run Code Online (Sandbox Code Playgroud)

这在Ant手册中有记录.


Phi*_*hil 5

另一种方法是使用 antcall,如果您想并行运行依赖的目标,它会更灵活。假设 compile 和 jsps 可以并行运行(即以任何顺序),则所有目标都可以写为:

<target name="all" description="all target, parallel">
  <parallel threadCount="2">
    <antcall target="compile"/>
    <antcall target="jsps"/>
  </parallel>
</target>
Run Code Online (Sandbox Code Playgroud)

请注意,如果目标不能并行运行,最好使用第一个带有依赖属性的风格,因为蚂蚁调用仅在执行时解析,如果被调用的目标不存在,则构建只会在该点失败。