ant 依赖 vs. antcall [英] ant depends vs. antcall

查看:28
本文介绍了ant 依赖 vs. antcall的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在定义顺序构建步骤时,我使用 target 元素的 depends 属性.我最近看到一个 ant 文件,其中构建序列由目标内的 antcall 元素定义.举例说明:

When defining sequential build steps I use the depends attribute of the target element. I have recently seen an ant file, where the build sequence was defined by antcall elements inside the targets. To illustrate :

<target name="a" depends="b">
...</target>

对比

<target name="a">
<antcall target="b"/>
...</target>

这两种方法之间有真正的区别吗?其中之一更可取?

Is there a real difference between the two approaches? Is one of them preferable?

推荐答案

两种方法的主要区别在于depends中的目标always被执行,而antcall 仅在包含目标时执行.

The main difference between both approaches is that targets in depends are always executed, while targets in antcall are executed only if the containing target is.

一个说明性的例子:

<target name="a" depends="b" if="some.flag">

</target>

这里,b会一直被执行,而a只会在some.flag被定义后才会被执行.

Here, b will always be executed, while a will be executed only if some.flag is defined.

<target name="a" if="some.flag">
    <antcall target="b" />
</target>

这里,b 只会在 a 是,即如果 some.flag 被定义时才会被执行.

Here, b will only be executed if a is, i.e. if some.flag is defined.

这篇关于ant 依赖 vs. antcall的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆