4

My project structure is look like

Root + subproj1
     + subproj2

in each sub project defined his own task run(){}. What i'm trying to do is run :subproj1:run, :subproj2:run in parallel from Root project's run task. I tried in root project's build.gradle

task run(){
  def threads = 2
  def tasks = [ ":subproj1:run", ":subproj2:run" ]
  tasks.each {
    new Thread(){
      public void run(){
        dependsOn it
      }
    }.start();
  }
}

but it makes an exception like

Exception in thread "Thread-12" org.gradle.api.UnknownProjectException:
Project with path ':subproj1:run' could not be found in root project 'ROOT'

How i can run sub project's task in parallel from root project?

moon
  • 156
  • 2
  • 9

2 Answers2

3

With gradle 2.1 it should work out of the box. One solution is --parallel like Perryn said or you set org.gradle.parallel:true into your gradle.properties. And then you should be able to run "gradle run" in the root project and both should be executed parallel.

I also put undeclared-project-coupling=fail into gradle.properties to know if they are coupled and can't be executed in parallel.

Hillkorn
  • 633
  • 4
  • 12
1

have you tried looking at the --parallel command line option?

Perryn Fowler
  • 2,192
  • 1
  • 12
  • 20