Run top-level tasks sequentially, but dependent tasks in parallel


I’m wondering whether there is an elegant way with

./gradlew taskA taskB taskC

to run all these top-level tasks sequentially, but their respective dependent tasks in parallel (if they allow it). That is, I’d like to get taskA executed, and if it has dependencies on other tasks allow these tasks to run in parallel. Once taskA has (successfully) finished, execute taskB and its dependencies similarly, and finally do the same for taskC.

The current behavior (of Gradle 5.6.2) seems to be to run all tasks in parallel if possible. The potential downside of this is, if taskA by itself is a very short running task, it might take much longer to execute if run in parallel with taskB, which is unfavorable if you want to fail fast.

So my goal is to run quick check tasks first, and then more expensive ones, ideally in one command line call, and not like ./gradlew taskA && ./gradlew taskB && ./gradlew taskC. Is this currently possible somehow?

Hi Sebastian,

the only way to achieve what you want is to use mustRunAfter or shouldRunAfter on the tasks you currently support. There is no built-in way to do what you want.


Thanks for the confirmation of what I though! :slight_smile: