Using ParallelizableTask

The docs indicate that I can mark specific tasks as parallelizable using the @ParallelizableTask annotation. As far as I can tell, this annotation doesn’t do anything. Am I missing a piece here, or misunderstanding the purpose of this annotation?

Example build.gradle below - my “taska” and “taskb” scripts are simple bash scripts that do echo "start"; sleep 5; echo "end". With the code below, I see that the tasks are executed separately in series. Can I get them to execute in parallel?

class ParallelTask extends Exec {}

task taska(type: ParallelTask) {
    commandLine './taska'

task taskb(type: ParallelTask) {
    commandLine './taskb'

By default, it doesn’t do anything. It’s a hint for the task executor to schedule the task to run in parallel.

There’s not a public way to turn this check on (i.e., a command-line flag), but we do have a hidden system property to enable more aggressive parallel execution:

We have test coverage for using this, but it’s possible to write unsafe tasks that we can’t detect as non-parallel safe, so we haven’t taken the time to make this public. Anecdotally, I use this for the gradle build all the time and haven’t noticed any problems. I think eventually this is going to get rolled into --parallel and/or be enabled by default.

Thanks for the tip. I tried this:

gradle -Dorg.gradle.parallel.intra=true taska taskb

but it still doesn’t seem to make a difference. I also tried creating a 3rd task that just depends on the other two and executing that (in case dependencies are parsed differently from tasks directly on the command line), but still no luck. I’m using Gradle 2.11 by the way.

I can dive into the source a little more and see what I can figure out, but let me know if you can think of anything else I’m missing. Thanks!

Ah, sorry. You have to enable --parallel too. I forgot I had org.gradle.parallel=true in my ~/.gradle/

Yea, I think I have it in my as well - would need to double check that machine to be sure, but I usually have that set.

Just got to check up on this again - and it turns out I didn’t have org.gradle.parallel set on this particular machine. Passing --parallel made things work. Thanks for the help!