I have a path as follows:
<path refid="myjarlocation"/>
Now I want to iterate over this path and for each value present in the path I want to call a macrodef with that value as one of the property to be used inside the marcodef.
In case of target we can easily do it as follows:
<foreach target="mytarget" param="jarloc">
<path refid="myjarlocation"/>
</foreach>
I cannot use for each because I need to pass multiple parameters , so I am using macrodef. So, therefore the question how to iterate over a path and call a macrodef instead of a target.
I've made something similar work by using ant-contrib's
fortask to iterate a path and passing the path element along to a macrodef.First get ant-contrib in your project - see http://ant-contrib.sourceforge.net/
Next, define your macrodef in your ant build however you want including some attribute that will take your path element. eg:
Then, use the
fortask to iterate the path into pathelements and invoke the macro:Note the use of
@{path.element}as opposed to${path.element}inside the for loop to refer to the looping parameter!