2

I have these tasks in a multi-project build:

task runA(type: GradleBuild) {
    tasks = [
         ':a:x:bootRun',
         ':a:y:bootRun',
         ':c:x:bootRun'
    ]
}

task runB(type: GradleBuild) {
    tasks = [
         ':b:x:bootRun',
         ':b:y:bootRun',
         ':c:x:bootRun'
    ]
}

Each :a:x etc. is a separate project (build.gradle / build.gradle.kts file). When I invoke gradle runA or gradle runB all of the subtasks are run in parallel just as they should.

However, when I run gradle runA runB only some of the tasks get invoked while I want all five unique tasks a:x a:y c:x b:x b:y to be run in parallel. I have also tried using dependsOn instead of the GradleBuild task type but that leads to the same outcome (usually only 4 of 5 expected tasks run in parallel).

Note that the tasks never "complete" as they run an application, I'm more or less abusing gradle as a launcher of sorts here. I assume gradle blocks and waits for one of the tasks to complete but there are no dependencies between them.

What do I need to do to force gradle to run all of the tasks in parallel at the same time?

Johannes Rudolph
  • 35,298
  • 14
  • 114
  • 172
  • I don't experience what you said. Doing `gradle runA` does not run all the tasks in parallel. I actually have to do `gradle --parallel runA` for that to work – smac89 Dec 19 '19 at 19:29

1 Answers1

0

Gradle will use heuristics to decide how many things to run in parallel. So the most likely explanation is that by default it is limiting itself to 4 parallel tasks.

You can control this via gradle.properties:

org.gradle.workers.max=(max # of worker processes)
Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
  • Thanks, I've checked this (12 on my machine is the default, setting it explicitly didn't help either). The funny thing is that a `runX` task with all 5 tasks listed directly works as it should... – Johannes Rudolph May 25 '19 at 13:29