I am trying to capture the output written from each task as it progresses. The code below works as expected when running Gradle using -max-employees 1, but when several tasks are executed in parallel, this code below picks up the output written from other tasks performed simultaneously.
The API documentation states the following about the getLogging method in Task. From what he says, I judge that he should support capturing output from individual tasks regardless of any other tasks being performed at the same time.
getLogging () Returns a LoggingManager that can be used to control the logging level and standard output / error capture for this task. https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html
graph.allTasks.forEach { Task task ->
task.ext.capturedOutput = [ ]
def listener = { task.capturedOutput << it } as StandardOutputListener
task.logging.addStandardErrorListener(listener)
task.logging.addStandardOutputListener(listener)
task.doLast {
task.logging.removeStandardOutputListener(listener)
task.logging.removeStandardErrorListener(listener)
}
}
Am I messing up something in the code above or should I report it as an error?
source
share