Reputation: 19453
Can I write an ant task which takes parameters when being executed from another ant task?
What I try to achieve in general, is re-using existing tasks with different parameters.
What I don't know is:
Concept of what I need to achieve:
Sub Ant task, which takes parameters param1 and param2:
<someAntCommand att="$param1"/>
<someOtherAntCommand att="$param2"/>
Main Ant task, which executes the sub task:
<doSomethingToExecSubTask somePointerToTaskOrFile="...">
<param name="param1"> hello </param>
<param name="param2"> world </param>
</doSomethingToExecSubTask>
<doSomethingToExecSubTask somePointerToTaskOrFile="...">
<param name="param1"> hello </param>
<param name="param2"> universe </param>
</doSomethingToExecSubTask>
Upvotes: 7
Views: 10941
Reputation: 4503
What you want is macro-def.
For a really good guide to writing Ant macros check out this presentation.
Upvotes: 2
Reputation: 698
<property name="param1"/>
<property name="param2"/>
<target name="task1">
<property name="param1" value="hello"/>
<property name="param2" value="world"/>
</target>
<target name="task2">
</target>
Just call task2, task run will run before it
Upvotes: 0