user4501728
user4501728

Reputation:

Parallelizing ant like GNU Make?

I need to execute multiple ant tasks. They haven't to run in the same JVM, a gnu make-like fork()-ed execution is this time perfect(*).

But, what I need, it were a functionality with the gnu make can with the -j flag: I need to be able to limit the maximal number of tasks running parallel. It is the main problem, in my current tries (subant task) I didn't find any option for that.

So, is there a solution for the problem? I really won't call a gnu make with an exec task...

(*) Yes, I know it is ineffecient, please don't worry because of that. In normal circumstances I also prefer a multithreaded solution, but now there are special circumstances.

Upvotes: 1

Views: 63

Answers (1)

Alex
Alex

Reputation: 2485

You can use the <parallel> task in ant, the doc's describe it as this:

Executes nested tasks in parallel with no guarantees of thread safety. Every task will run in its own thread, with the likelihood of concurrency problems scaling with the number of CPUs on the host system.

Example (from their docs):

<parallel threadCount="4">
  <dbpurge file="db/one" />
  <dbpurge file="db/two" />
  <dbpurge file="db/three" />
  <dbpurge file="db/four" />
  <dbpurge file="db/five" />
  <dbpurge file="db/six" />
  <dbpurge file="db/seven" />
  <dbpurge file="db/eight" />
  <!-- repeated about 40 times -->
</parallel>

Upvotes: 1

Related Questions