我的任务如下:
<target name="someTarget">
<concat destfile="someFile">
<string>someString</string>
<string>someOtherString</string>
</concat>
</target>
<target name="someOtherTarget">
<antcall target="someTarget">
<param name="myParam" value="myValue"></param>
</antcall>
<antcall target="someTarget">
</antcall>
</target>
如果在调用someOtherString
目标时提供myParam
,我如何连接someTarget
?
答案 0 :(得分:4)
如果没有Ant扩展,只需使用conditional Ant execution:
<project default="someOtherTarget">
<target name="someTarget" depends="-someString,-someOtherString"/>
<target name="-someString" unless="myParam">
<concat destfile="someFile">
<string>someString</string>
</concat>
</target>
<target name="-someOtherString" if="myParam">
<concat destfile="someOtherFile">
<string>someString</string>
<string>someOtherString</string>
</concat>
</target>
<target name="someOtherTarget">
<antcall target="someTarget">
<param name="myParam" value="myValue"></param>
</antcall>
<antcall target="someTarget"/>
</target>
</project>
如果您不介意在项目中添加Ant扩展程序,请查看Ant-Contrib的If task。