Bug 1580280 - [gradle] Stop redirecting stderr into stdout when calling 'mach environment', r?nalexander draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 27 Sep 2019 16:22:01 -0400
changeset 2358861 d48e5cd2234a656b625d45e133038e00847b97dc
parent 2358603 b19e0c207cfd521f933583ca1293d62c34ead546
child 2358862 9e634e1593f622c88f60ecec6c7000304928644c
push id429033
push userahalberstadt@mozilla.com
push dateMon, 30 Sep 2019 14:28:02 +0000
treeherdertry@8f341e56b310 [default view] [failures only]
reviewersnalexander
bugs1580280
milestone71.0a1
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
settings.gradle
--- a/settings.gradle
+++ b/settings.gradle
@@ -10,22 +10,23 @@ if (System.properties['os.name'].toLower
         def mozillabuild = System.env.MOZILLABUILD
         if (mozillabuild) {
             commandLine.addAll(0, ["${mozillabuild}/python/python.exe"])
         }
     }
 }
 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
 
 def slurper = new JsonSlurper()
 def json = slurper.parseText(standardOutput.toString())
 
 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {