ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <>
Subject Re: Parallel task...
Date Wed, 24 Jan 2007 19:40:51 GMT
> i'm looking at the use of the parallel task to run some optional jobs
> during my build.  this looks like it would be perfect for doing things
> like javadoc, junit, jprobe, etc. however, i would like to be able to
> switch my optional tasks so that they are only run if a flag was set.
> currently i have each of them in their own target and use the
> if="flag_set" attribute in the target.  but this doesn't allow me to
> run them in parallel.  is there a way to run these as 'switched' tasks
> within a parallel target?

That's an usual request.

> <target name="junit" depends="package" if="run_junit">
>   <ant antfile="junit.xml />
> </target>
> <target name="javadoc" depends="package" if="run_javadoc">
>   <ant antfile="javadoc.xml" />
> </target>

Ah, each of these is its own build file!

In this case, what I'd do is use <exec spawn="${in-parallel}"> to run
the (optional) sub-build, in it's own process. Simply changing the
value of the 'in-parallel' property changes the behavior from
sequential to parallel. This way, you achieve parallelism at the
process level, and not the thread level, which should be more robust

Then your 'optional_tasks' target simply depends on the other targets
to spawn, and an additional one that simply sets the right properties
to get the behaviour you want in the former.

With spawn="true", you loose the output of the spawed process, but you
can configure that process to log to a file. There are examples in the
archieves to emulate <ant fork="true"> with <java> or <exec>, and
adding spawn="true" is simply a variation.

Probably not what you wanted to hear, sorry ;-)

I've used Ant for a long time, but except for parallel-<get>s one
time, I've shied away from <parallel>, as many weird things can happen
in Ant with it, IMHO. It's not a task for the faint-of-heart ;-) Good
luck, --DD

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message