Run two subproject tasks simultaneously

I have a monorepo setup such as:


I’ve two separate tasks which build and run a development server: :api:bootRun and :webapp:runDev.

Is it possible to get these two tasks to run in parallel? They are not dependent on each other until the build task bootJar is run - which is outside the scope.

I’m currently trying to work around this using GPars, but to no avail:

tasks.register("dev") {
    def tasksToRun = ['api:bootRun', 'webapp:runDev']

    GParsPool.withPool { ExecutorService svc -> 
        tasksToRun.each { taskToRun ->

def runDevTaskFromProject(String projectTask) {
    try {
        String[] components = projectTask.split(':')
            .withProjectDir("$projectDir/" + components[0])
    } catch (Exception e) {
        println "Run Failed " + e

Is there a better way of doing this - or do I need to write something based on the Workers API to facilitate this?

Things using the worker api and do not depend on each other can run in parallel, even within one project, yes.
Another point is, that --parallel or org.gradle.parallel enables tasks of different projects to run in parallel, so would probably also help you.

Thanks @Vampire

I believe org.gradle.parallel=true is set in the project level;

How would I structure the parent task to use with --parallel?

The property and parameter do the same.
But no idea what you mean with your question.

@Vampire for the question, how do I write that task so that the two subtasks (which have different names) are called in parallel?

Just depend on them I guess?

Wow - that worked, I didn’t know parallel worked on dependsOn thanks :slight_smile: