Bug 1125330 - Expose |mach| output after failures invoking from Gradle. r=me,f=ally

This commit is contained in:
Nick Alexander 2015-01-27 21:41:14 -08:00
parent af6730dabc
commit baa0cc39ea
3 changed files with 27 additions and 7 deletions

View File

@ -33,5 +33,15 @@ subprojects {
commandLine "${topsrcdir}/mach"
args 'build'
args 'mobile/android/base/gradle-targets'
// Only show the output if something went wrong.
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
errorOutput = standardOutput
doLast {
if (execResult.exitValue != 0) {
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
}
}
}
}

View File

@ -23,6 +23,16 @@ task buildOmnijar(type:Exec) {
args '-C'
args 'mobile/android/base'
args 'gradle-omnijar'
// Only show the output if something went wrong.
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
errorOutput = standardOutput
doLast {
if (execResult.exitValue != 0) {
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
}
}
}
apply plugin: 'idea'

View File

@ -8,20 +8,20 @@ if (!hasProperty('topsrcdir')) {
logger.warn("topsrcdir is undefined: assuming source directory Gradle invocation with topsrcdir=${topsrcdir}.")
}
def command = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
def proc = command.execute(null, new File(topsrcdir))
def sout = new StringBuffer()
def serr = new StringBuffer()
proc.consumeProcessOutput(sout, serr)
def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
def proc = commandLine.execute(null, new File(topsrcdir))
def standardOutput = new ByteArrayOutputStream()
proc.consumeProcessOutput(standardOutput, standardOutput)
proc.waitFor()
// Only show the output if something went wrong.
if (proc.exitValue() != 0) {
throw new GradleException("Could not extract mozconfig/build environment from |${topsrcdir}/mach environment|!");
throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n${standardOutput.toString()}")
}
import groovy.json.JsonSlurper
def slurper = new JsonSlurper()
def json = slurper.parseText(sout.toString())
def json = slurper.parseText(standardOutput.toString())
include ':app'
include ':base'