gradlew now offering a --strict flag as a subset of --ci
Now --strict enables all flags that are supposed to be able to improve correctness or reproducibility
Now --ci enables --strict and also enables some other flags that are specific to running on the build serer, like dumping a stacktrace and attempting to send a short error summary to stderr
Also, making validateNoUnrecognizedMessages no longer imply summarizeStderr (in case a user wants to pass "--strict" but not see stacktraces or repeat error summaries)
Bug: 170903505
Test: Run `./gradlew :help --ci` and see that the top of the output says this:
gradlew expanded '--ci' into '--strict --stacktrace -Pandroidx.summarizeStderr -Pandroidx.coverageEnabled=true -Pandroidx.enableAffectedModuleDetection --no-watch-fs'
gradlew expanded '--strict' into '-Pandroidx.allWarningsAsErrors -Pandroidx.validateNoUnrecognizedMessages -PverifyUpToDate --no-watch-fs --no-daemon --offline'
Test: ./gradlew :help --ci 2>&1 | grep "To honour the JVM settings for this build a single-use Daemon process will be forked" # and see that "--no-daemon" (from "--strict") is still passed
Test: ./gradlew misspelled --ci # and see that this prints a stacktrace due to "--stacktrace"
Test: ./gradlew --strict :help # and see that it fails due to the :help task creating extra output
Test: ./gradlew misspelled --strict # and see that there is no stacktrace and no summary from build_log_simplifier
Test: ./gradlew :core:core:assemble --strict # and see that this passes
Test: Treehugger runs busytown/*.sh
Change-Id: Ia69fca048f1bad5599f17cd3266c5c24c77ca29c
diff --git a/gradlew b/gradlew
index 3b76e03..f5d3479c 100755
--- a/gradlew
+++ b/gradlew
@@ -222,39 +222,48 @@
TMPDIR_ARG="-Djava.io.tmpdir=$TMPDIR"
fi
-# expand the "--ci" flag
-compact="--ci"
-expanded="--stacktrace\
- -Pandroidx.summarizeStderr\
- -Pandroidx.allWarningsAsErrors\
- -Pandroidx.coverageEnabled=true\
- -Pandroidx.enableAffectedModuleDetection\
- -Pandroidx.validateNoUnrecognizedMessages\
- -PverifyUpToDate\
- --no-watch-fs\
- --no-daemon\
- --offline"
-# Make a copy of our list of arguments, and iterate through the copy
-for arg in "$@"; do
- # Remove this argument from our list of arguments.
- # By the time we've completed this loop, we will have removed the original copy of
- # each argument, and potentially re-added a new copy or an expansion of each.
- shift
- # Determine whether to expand this argument
- if [ "$arg" == "$compact" ]; then
- # Add the expansion to our arguments
- set -- "$@" $expanded
- echo "gradlew expanded '$compact' into '$expanded'"
- echo
- # We avoid re-adding this argument itself back into the list for two reasons:
- # 1. This argument might not be directly understood by Gradle
- # 2. We want to enforce that all behaviors enabled by this flag can be toggled independently,
- # so we don't want it to be easy to inadvertently check for the presence of this flag
- # specifically
- else
- # Add this argument back into our arguments
- set -- "$@" "$arg"
+# Expand some arguments
+for compact in "--ci" "--strict"; do
+ if [ "$compact" == "--ci" ]; then
+ expanded="--strict\
+ --stacktrace\
+ -Pandroidx.summarizeStderr\
+ -Pandroidx.coverageEnabled=true\
+ -Pandroidx.enableAffectedModuleDetection\
+ --no-watch-fs"
fi
+ if [ "$compact" == "--strict" ]; then
+ expanded="-Pandroidx.allWarningsAsErrors\
+ -Pandroidx.validateNoUnrecognizedMessages\
+ -PverifyUpToDate\
+ --no-watch-fs\
+ --no-daemon\
+ --offline"
+ fi
+
+ # Expand an individual argument
+ # Start by making a copy of our list of arguments and iterating through the copy
+ for arg in "$@"; do
+ # Remove this argument from our list of arguments.
+ # By the time we've completed this loop, we will have removed the original copy of
+ # each argument, and potentially re-added a new copy or an expansion of each.
+ shift
+ # Determine whether to expand this argument
+ if [ "$arg" == "$compact" ]; then
+ # Add the expansion to our arguments
+ set -- "$@" $expanded
+ echo "gradlew expanded '$compact' into '$expanded'"
+ echo
+ # We avoid re-adding this argument itself back into the list for two reasons:
+ # 1. This argument might not be directly understood by Gradle
+ # 2. We want to enforce that all behaviors enabled by this flag can be toggled independently,
+ # so we don't want it to be easy to inadvertently check for the presence of this flag
+ # specifically
+ else
+ # Add this argument back into our arguments
+ set -- "$@" "$arg"
+ fi
+ done
done
function tryToDiagnosePossibleDaemonFailure() {