1
我想執行目標「MyTarget」,並得到一個錯誤:「不支持的元素回聲」。也許Macrodef不是做這項工作的方式。有沒有其他方式將任務傳遞給具有不同參數的另一個目標/宏定義?如何使用不同的參數幾次運行自定義任務?
<macrodef name="dotask">
<attribute name="platform" description="" />
<attribute name="config" description="" />
<element name="task2" optional="true" />
<sequential>
<task2 />
</sequential>
</macrodef>
<macrodef name="buildsuite2">
<element name="task" optional="true" />
<sequential>
<dotask platform="win32" config="debug">
<task />
</dotask>
<dotask platform="win32" config="release">
<task />
</dotask>
</sequential>
</macrodef>
<target name="MyTarget">
<buildsuite2>
<task>
<echo>${platform} ${config}</echo>
</task>
</buildsuite2>
</target>
我有一組PARAMS將重新使用了相當數量的自定義任務。做你的建議可能會解決這個問題,但我必須爲每個參數組寫一個antcall。如果我添加一個新的參數集,我必須爲每個自定義任務添加一個新的antcall。 –
@Chau你可以使用[macrodef](http://ant.apache.org/manual/Tasks/macrodef.html)和antcall來分解公共代碼。 – sudocode