在Ant中,我可以在目标';s";视情况而定;?
我正试着用Ant做这件事:在Ant中,我可以在目标';s";视情况而定;?,ant,Ant,我正试着用Ant做这件事: <property name="test" value="123"/> <target name="helloworld" depends="${test}"/> 但我得到的错误是“目标${test}在此项目中不存在。” 所以我猜我能做到这一点吗?您可以使用if属性检查属性,而不是依赖它。有关更多详细信息,请参阅 例如: <target name="helloworld" if="test"/> 您可以使用调用另一个任务中的
<property name="test" value="123"/>
<target name="helloworld" depends="${test}"/>
但我得到的错误是“目标${test}在此项目中不存在。”
所以我猜我能做到这一点吗?您可以使用if属性检查属性,而不是依赖它。有关更多详细信息,请参阅 例如:
<target name="helloworld" if="test"/>
您可以使用调用另一个任务中的任务
<project>
<target name="asdf">
<property name="prop" value="qwer" />
<antcall target="${prop}" />
</target>
<target name="qwer">
<echo message="in qwer" />
</target>
</project>
要使一个任务依赖于另一个任务,可以在依赖任务中设置一个参数,并在调用任务中检查该参数
<project>
<target name="asdf">
<property name="prop" value="qwer" />
<antcall target="${prop}" />
</target>
<target name="qwer">
<echo message="in qwer" />
</target>
</project>