gpt4 book ai didi

ant - 按什么顺序评估Ant目标的 “if”和 “depends”?

转载 作者:行者123 更新时间:2023-12-03 12:13:49 25 4
gpt4 key购买 nike

也就是说,当testSetupDone评估为false时,将调用以下目标,并在依赖关系链中执行目标吗?

<target name="-runTestsIfTestSetupDone" if="testSetupDone" depends="-runTests" />

最佳答案

是的,将在评估条件之前执行依赖项。

Ant manual:

Important: the if and unless attributes only enable or disable the target to which they are attached. They do not control whether or not targets that a conditional target depends upon get executed. In fact, they do not even get evaluated until the target is about to be executed, and all its predecessors have already run.



您也可以尝试一下:
<project>
<target name="-runTests">
<property name="testSetupDone" value="foo"/>
</target>
<target name="runTestsIfTestSetupDone" if="testSetupDone" depends="-runTests">
<echo>Test</echo>
</target>
</project>

我在依赖目标中设置属性 testSetupDone,输出为:
Buildfile: build.xml

-runTests:

runTestsIfTestSetupDone:
[echo] Test

BUILD SUCCESSFUL
Total time: 0 seconds

即使此时未设置 -runTests,也会执行目标 testSetupDone,然后再执行 runTestsIfTestSetupDone,因此在 depend之前(使用Ant 1.7.0)将 评估为

关于ant - 按什么顺序评估Ant目标的 “if”和 “depends”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4014094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com