Logging.captureStandardOutput does not capture all stdout when running in parallel


(Thomas Grönwall) #1

Hi

I have encountered a problem with captureStandardOutput when running several projects in parallel.

The problem is that although I have set logging to capture stdout to log level INFO I get output (on the default lifecycle level) from some sub-projects, but not all. The number of projects emitting the task output is dependent of the number of parallel threads.

In my small setup described below I have four sub-projects besides the root project. If I set parallel-threads=1 (or up to 4) there is no output, which is the correct behavior in this case. But if I set parallel-threads=5, I get output from one of the projects. With parallel-threads=7, I get output from two of the projects.

This can be easily reproduced by creating a small build.gradle file with this:

defaultTasks 'printSomething'
wrapper {
    gradleVersion = '1.10'
}
allprojects {
  task printSomething << {
     logging.captureStandardOutput LogLevel.INFO
     project.exec {
         commandLine "echo", "******************* $project *********************"
     }
  }
}

and a settings.gradle:

include "sub1", "sub2", "sub3", "sub4"

and the empty folders “sub1”, “sub2”, “sub3”, “sub4”

Output:

$ ./gradlew --parallel-threads=4
Parallel execution is an incubating feature.
:printSomething
:sub3:printSomething
:sub2:printSomething
:sub1:printSomething
:sub4:printSomething
  $ ./gradlew --parallel-threads=6
Parallel execution is an incubating feature.
:printSomething
:sub4:printSomething
:sub3:printSomething
:sub2:printSomething
:sub1:printSomething
******************* project ':sub2' *********************
  $ ./gradlew --parallel-threads=7
Parallel execution is an incubating feature.
:printSomething
:sub4:printSomething
:sub3:printSomething
:sub2:printSomething
:sub1:printSomething
******************* project ':sub4' *********************
******************* root project 'gradlebug' *********************

I have run this on macos 10.9.1


(Luke Daley) #2

Congratulations, you made GRADLE-3000 :slight_smile: