Bug 1580280 - [gradle] Stop redirecting stderr into stdout when calling 'mach environment', r=nalexander

Print debugging a task that runs gradle has been really annoying as gradle
reads the output of 'mach environment' and fails as soon as a debug line shows
up.

What's worse, is it redirects stderr into stdout so even printing to
'sys.stderr' fails. This fixes that so writing to stderr will at least work.

Differential Revision: https://phabricator.services.mozilla.com/D47608

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Halberstadt 2019-09-30 19:42:11 +00:00
parent 35d00cbafb
commit 3ccc9e7376

View File

@ -15,12 +15,13 @@ if (System.properties['os.name'].toLowerCase().contains('windows')) {
}
def proc = commandLine.execute(null, new File(topsrcdir))
def standardOutput = new ByteArrayOutputStream()
proc.consumeProcessOutput(standardOutput, standardOutput)
def standardError = new ByteArrayOutputStream()
proc.consumeProcessOutput(standardOutput, standardError)
proc.waitFor()
// Only show the output if something went wrong.
if (proc.exitValue() != 0) {
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\nstdout:\n${standardOutput.toString()}\n\nstderr:\n${standardError.toString()}")
}
import groovy.json.JsonSlurper