Running build_log_simplifier.py in androidx-studio-integration.sh too
Test: ./gradlew projects && echo ok
Test: ./gradlew nonexistenttask && echo nope # and see that this fails
Test: ./busytown/androidx.sh nonexistenttask # and see that this fails with a stacktrace but that it is short
Test: Run `echo "syntaxerror" >> core/core/src/main/java/androidx/core/app/AppComponentFactory.java && ./busytown/androidx-studio-integration.sh` and see that it fails with a stacktrace but that it is short
Change-Id: Ia0e3ca99a85fd9bd2fbd4a12bb79b0fa96eb6842
diff --git a/busytown/androidx-studio-integration.sh b/busytown/androidx-studio-integration.sh
index c09984af..df9c477 100755
--- a/busytown/androidx-studio-integration.sh
+++ b/busytown/androidx-studio-integration.sh
@@ -32,5 +32,7 @@
export JAVA_TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
export LINT_PRINT_STACKTRACE=true
-$gw -p frameworks/support --no-daemon bOS --stacktrace -Pandroidx.allWarningsAsErrors
-DIST_SUBDIR="/ui" $gw -p frameworks/support/ui --no-daemon bOS --stacktrace -Pandroidx.allWarningsAsErrors
+LOG_SIMPLIFIER="$SCRIPT_DIR/../development/build_log_simplifier.sh"
+
+"$LOG_SIMPLIFIER" $gw -p frameworks/support --no-daemon bOS --stacktrace -Pandroidx.allWarningsAsErrors
+"$LOG_SIMPLIFIER" DIST_SUBDIR="/ui" $gw -p frameworks/support/ui --no-daemon bOS --stacktrace -Pandroidx.allWarningsAsErrors
diff --git a/busytown/impl/build.sh b/busytown/impl/build.sh
index 4ec9bde..c400e90 100755
--- a/busytown/impl/build.sh
+++ b/busytown/impl/build.sh
@@ -30,7 +30,7 @@
# display the contents of the out/ directory, to allow us to be sure that it was empty before this build started
echoAndDo "ls -la out"
-# run gradle
-# "androidx.summarizeStderr" outputs an error summary message. See gradlew for details
-echoAndDo OUT_DIR=out/ui DIST_DIR=$DIST_DIR/ui ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/ui/gradlew -p frameworks/support/ui --stacktrace -Pandroidx.summarizeStderr "$@"
-echoAndDo OUT_DIR=out DIST_DIR=$DIST_DIR ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/gradlew -p frameworks/support --stacktrace -Pandroidx.summarizeStderr "$@"
+LOG_SIMPLIFIER="$SCRIPT_DIR/../../development/build_log_simplifier.sh"
+
+"$LOG_SIMPLIFIER" OUT_DIR=out/ui DIST_DIR=$DIST_DIR/ui ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/ui/gradlew -p frameworks/support/ui --stacktrace -Pandroidx.summarizeStderr "$@"
+"$LOG_SIMPLIFIER" OUT_DIR=out DIST_DIR=$DIST_DIR ANDROID_HOME=./prebuilts/fullsdk-linux frameworks/support/gradlew -p frameworks/support --stacktrace -Pandroidx.summarizeStderr "$@"
diff --git a/development/build_log_simplifier.sh b/development/build_log_simplifier.sh
new file mode 100755
index 0000000..e2093bc
--- /dev/null
+++ b/development/build_log_simplifier.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+set -e
+
+usage() {
+ echo "usage: $0 <command> <arguments>"
+ echo
+ echo "executes <command> <arguments> and then runs build_log_simplifier.py against its output"
+ exit 1
+}
+
+if [[ "$1" == "" ]]; then
+ usage
+fi
+
+# run Gradle and save stdout and stderr into $logFile
+SCRIPT_PATH="$(cd $(dirname $0) && pwd)"
+if [ -n "$DIST_DIR" ]; then
+ LOG_DIR="$DIST_DIR"
+else
+ LOG_DIR="$SCRIPT_PATH/../../../out/dist"
+fi
+
+mkdir -p "$LOG_DIR"
+logFile="$LOG_DIR/gradle.log"
+rm -f "$logFile"
+echo "Running $@"
+if bash -c "$*" > >(tee -a "$logFile") 2> >(tee -a "$logFile" >&2); then
+ echo "Succeeded: $*"
+else
+ echo >&2
+ echo "Failed: $*" >&2
+ echo Attempting to locate the relevant error messages via build_log_simplifier.py >&2
+ echo >&2
+ # Try to identify the most relevant lines of output, and put them at the bottom of the
+ # output where they will also be placed into the build failure email.
+ # TODO: We may be able to stop cleaning up Gradle's output after Gradle can do this on its own:
+ # https://github.com/gradle/gradle/issues/1005
+ # and https://github.com/gradle/gradle/issues/13090
+ summaryLog="$LOG_DIR/error_summary.log"
+ $SCRIPT_PATH/build_log_simplifier.py $logFile | tail -n 100 | tee "$summaryLog" >&2
+ exit 1
+fi
diff --git a/gradlew b/gradlew
index 49facc3..db30cc3 100755
--- a/gradlew
+++ b/gradlew
@@ -240,49 +240,15 @@
fi
}
-# Runs a build and possibly modifies the output before displaying it, to make it easier to
-# interpret, and to make the relevant error messages fit inside of build failure emails.
-function runBuild() {
- if [[ " ${@} " =~ " -Pandroidx.summarizeStderr " ]]; then
- # run Gradle and save stdout and stderr into $logFile
- if [ -n "$DIST_DIR" ]; then
- LOG_DIR="$DIST_DIR"
- else
- LOG_DIR="$OUT_DIR/dist"
- fi
- mkdir -p "$LOG_DIR"
- logFile="$LOG_DIR/gradle.log"
- rm -f "$logFile"
- if runGradle "$@" > >(tee -a "$logFile") 2> >(tee -a "$logFile" >&2); then
- echo Gradle success
- else
- echo >&2
- echo Gradle failure >&2
- echo Attempting to locate the relevant error messages via build_log_simplifier.py >&2
- echo >&2
- # Try to identify the most relevant lines of output, and put them at the bottom of the
- # output where they will also be placed into the build failure email.
- # TODO: We may be able to stop cleaning up Gradle's output after Gradle can do this on its own:
- # https://github.com/gradle/gradle/issues/1005
- # and https://github.com/gradle/gradle/issues/13090
- summaryLog="$LOG_DIR/error_summary.log"
- $SCRIPT_PATH/development/build_log_simplifier.py $logFile | tail -n 100 | tee "$summaryLog" >&2
- return 1
- fi
- else
- runGradle "$@"
- fi
-}
-
if [[ " ${@} " =~ " -PdisallowExecution " ]]; then
echo "Passing '-PdisallowExecution' directly is forbidden. Did you mean -PverifyUpToDate ?"
echo "See TaskUpToDateValidator.java for more information"
exit 1
fi
-runBuild "$@"
+runGradle "$@"
# Check whether we were given the "-PverifyUpToDate" argument
if [[ " ${@} " =~ " -PverifyUpToDate " ]]; then
# Re-run Gradle, and find all tasks that are unexpectly out of date
- runBuild "$@" -PdisallowExecution --continue --info
+ runGradle "$@" -PdisallowExecution --continue --info
fi