我有一个奇怪的问题与蚂蚁。我想有条件地执行了一步,所以我创建非常简单的例子:蚂蚁跑步时满足条件
<project name="TestProj" default="def">
<property name="prop1" value="xxx"/>
<target name="init">
<echo message="init step"/>
</target>
<target name="def" depends="init">
<echo message="def step"/>
<condition property="should.run">
<equals arg1="${prop1}" arg2="xxx"/>
</condition>
<echo message="outside check"/>
</target>
<target name="yes" if="${should.run}" depends="def">
<echo message="yeah,should run"/>
</target>
<target name="no" unless="${should.run}" depends="def">
<echo message="no,dont run"/>
</target>
输出是:
init:
[echo] init step
def:
[echo] def step
[echo] outside check
所以,我的条件步骤,不运行。
我的例子有什么问题?在此先感谢您的任何建议。
不是,if'和'unless'属性的行为会根据您是否提供属性名称或属性引用而改变。 run'被设置为'false'的值,如果'if =“$ {should.run}'会导致目标被跳过,但是如果if =”should.run“,目标仍然会运行。 – CAustin