我想編寫一個macrodef,它取決於在另一個macrodef中設置的屬性,例如this,這不起作用...(macrodef不支持depends,除非屬性)無論如何要做到這一點?ant'unless'on macrodef
<project name="mac">
<property name="antlr.version" value="3.2"/>
<macrodef name="check">
<attribute name="dest"/>
<attribute name="name"/>
<attribute name="version"/>
<sequential>
<available file="@{dest}/@{name}[email protected]{version}.jar" property="@{name}-exists"/>
</sequential>
</macrodef>
<macrodef name="pull" depends="check" unless="@{name}-exists">
<attribute name="url"/>
<attribute name="dest"/>
<attribute name="name"/>
<attribute name="version"/>
<sequential>
<get src="@{url}" dest="@{dest}/@{name}[email protected]{version}" verbose="true" ignoreerrors="true" unless="@{name}-exists"/>
</sequential>
</macrodef>
<target name="pullall">
<pull url="http://repo1.maven.org/maven2/org/antlr/antlr/${antlr.version}/antlr-${antlr.version}.jar" dest="." name="antlr" version="${antlr.version}"/>
</target>
關於macrodef的好處在於它可以在外部範圍內使用(在目標之前),因此此解決方案不考慮這一點。 – 2013-02-18 15:50:52