I have a monorepo setup such as:
monorepo
build.gradle
/api
build.gradle
/webapp
build.gradle
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 ->
svc.submit({runDevTaskFromProject(tasksToRun)})
}
}
}
def runDevTaskFromProject(String projectTask) {
try {
String[] components = projectTask.split(':')
GradleRunner.create()
.withProjectDir("$projectDir/" + components[0])
.withArguments(components[1])
.forwardOutput()
.build()
} catch (Exception e) {
println "Run Failed " + e
return
}
}
Is there a better way of doing this - or do I need to write something based on the Workers API
to facilitate this?