Problems redirecting standardOut for BuildLauncher


(Oliver Reißig) #1

I am using Gradle’s Tooling API to invoke nested builds in one of my tasks. I need stdout and stderr to be passed through and have some code that does the following:

GradleConnector connector = GradleConnector.newConnector().forProjectDirectory(projectDir)
ProjectConnection connection = connector.connect()
BuildLauncher launcher = connection.newBuild()
launcher.standardOutput = System.out
launcher.standardError = System.err
// disable for now, produces misaligned output
launcher.colorOutput = false

Recently we upgraded from Gradle 2.7 to 2.11 and now we start to have problems with this passthrough. Sometimes it works, sometimes it doesn’t. I haven’t found any pattern on why the behaviour is inconsistent. Does anyone have an idea?