tags:

views:

89

answers:

1

How to take the values of argument for a defined task into a list (of values) without to have to rewrite the task for each value of argument ?

Example: I want to avoid to have to rewrite three time the same task for echoing 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  A: 

You could use the MacroDef task to abstract the common 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"/>
Simon Lieschke