我使用的是ant,我有两个属性:testA和testB,都接受true或false。
在目标中我需要检查两者是否都是真的,但<target>
只接受一个if属性。
我该怎么做?
答案 0 :(得分:1)
使用<condition>
任务根据其他属性是否为真来创建新属性。
<project name="ant-target-multi-conditional" default="run">
<target name="init">
<property name="testA" value="true"/>
<property name="testB" value="true"/>
</target>
<target name="condition-check">
<condition property="both-are-true">
<and>
<istrue value="${testA}"/>
<istrue value="${testB}"/>
</and>
</condition>
</target>
<target name="run" depends="init,condition-check" if="both-are-true">
<echo>Both testA and testB are true.</echo>
</target>
</project>
init:
condition-check:
run:
[echo] Both testA and testB are true.