Ant <apply> in several directories

I want to simplify this:

<target name="build"> <parallel> <antcall target="build-A" /> <antcall target="build-B" /> <antcall target="build-C" /> </parallel> </target> <target name="build-A"> <exec executable="tool.exe" dir="projects/A"> <arg value="input.xml" /> </exec> </target> 

where build-B and build-C do the same (only in dirs B and C respectively), something similar to this:

 <dirset id="projects" dir="." > <include name="projects/*" /> </dirset> <apply executable="tool.exe" parallel="true"> <arg value="input.xml" /> <dirset refid="projects" /> </apply> 

This does not work because apply will do one of the following:

If parallel set to true ,

 tool.exe input.xml projects/A projects/B projects/C 

or if parallel set to false ,

 tool.exe projects/A/input.xml ...waits for tool.exe to complete... tool.exe projects/B/input.xml ...etc 

And even this is not true, because tool.exe awaiting execution in the projects/A directory.

Is there a way to parallelize this so that the output I get is equivalent:

 cd project/A tool.exe input.xml cd ../B tool.exe input.xml cd ../C tool.exe input.xml 

but in parallel?

+4
source share
1 answer

I would use ant-contrib for the task for this.

 <for param="dir" parallel="true"> <dirset id="projects" dir="." > <include name="projects/*" /> </dirset> <sequential> <exec executable="tool.exe" dir="@{dir}"> <arg value="input.xml" /> </exec> </sequential> </for> 
+4
source

All Articles