From baa0cc39ea966a6b66fd2596d8e94e2e616f20a4 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Tue, 27 Jan 2015 21:41:14 -0800 Subject: [PATCH] Bug 1125330 - Expose |mach| output after failures invoking from Gradle. r=me,f=ally --- mobile/android/gradle/build.gradle | 10 ++++++++++ mobile/android/gradle/omnijar/build.gradle | 10 ++++++++++ mobile/android/gradle/settings.gradle | 14 +++++++------- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/mobile/android/gradle/build.gradle b/mobile/android/gradle/build.gradle index 3dbfddd44ff..18ad7607137 100644 --- a/mobile/android/gradle/build.gradle +++ b/mobile/android/gradle/build.gradle @@ -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()}") + } + } } } diff --git a/mobile/android/gradle/omnijar/build.gradle b/mobile/android/gradle/omnijar/build.gradle index 3d906508097..44ea426383f 100644 --- a/mobile/android/gradle/omnijar/build.gradle +++ b/mobile/android/gradle/omnijar/build.gradle @@ -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' diff --git a/mobile/android/gradle/settings.gradle b/mobile/android/gradle/settings.gradle index 8ce2199a406..3c26b3f9acd 100644 --- a/mobile/android/gradle/settings.gradle +++ b/mobile/android/gradle/settings.gradle @@ -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'