39

如果我有三个目标, one all, onecompile和 one jsps,我将如何all依赖其他两个?

可不可能是:

<target name="all" depends="compile,jsps">

...或者是:

<target name="all" depends="compile","jsps">

或者也许是一些不同的东西?

我尝试搜索示例 ant 脚本以作为其基础,但我找不到具有多个依赖项的脚本。

4

4 回答 4

72

前者:

<target name="all" depends="compile,jsps">

这在Ant 手册中有记录。

于 2010-05-22T16:19:17.227 回答
11

这是最上面的。

如果您想自己快速查看,只需使用 echo 标签

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

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

<target name="all" depends="compile,jsps"></target>

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

于 2010-05-22T16:19:10.220 回答
10
<target name="all" depends="compile,jsps">

这在Ant 手册中有记录。

于 2010-05-22T16:19:57.260 回答
5

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

<target name="all" description="all target, parallel">
  <parallel threadCount="2">
    <antcall target="compile"/>
    <antcall target="jsps"/>
  </parallel>
</target>

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

于 2017-09-19T11:19:57.547 回答