How to distribute each element of a list into an argument of an Ant task?

How to accept argument values ​​for a given task into a list of (values) without rewriting the task for each argument value?

Example: I want to not rewrite the same task three times to repeat three different values ​​(value 1, value 2, value 3):

<exec executable="cmd"> <arg value="/c"/> <arg value="value 1"/> </exec> <exec executable="cmd"> <arg value="/c"/> <arg value="value 2"/> </exec> <exec executable="cmd"> <arg value="/c"/> <arg value="value 3"/> </exec> 

thanks

+4
source share
1 answer

You can use the MacroDef task to abstract the general part of your task:

 <macrodef name="myMacro"> <attribute name="value"/> <sequential> <exec executable="cmd"> <arg value="/c"/> <arg value="@{value}"/> </exec> </sequential> </macrodef> <myMacro value="value 1"/> <myMacro value="value 2"/> <myMacro value="value 3"/> 
+7
source

All Articles