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