Moving -PdisallowExecution logic out of build.py and into gradlew
and replacing it with -PverifyUpToDate which both runs Gradle once and then also runs Gradle again, verifying that the second build is up-to-date.
This means build.py can invoke fewer Gradle builds
Then if build.py fails, it can be easier for developers to identify how to reproduce the failure using gradlew invocations
These gradlew executions are then more familiar to developers and can be more easily customized
Bug: 140265313
Test: ./gradlew :annotation:annotation:assemble -PverifyUpToDate # and see that this runs Gradle twice and passes
Test: ./gradlew help -PverifyUpToDate # and see that Gradle runs twice and also that Gradle complains that the help task is not up-to-date
Test: ./gradlew help # and see that Gradle runs once
Test: echo syntax error >> build.gradle && ./gradlew help && echo success # and see that 'success' is not echoed
Change-Id: If9707075193a4918526035df2f985b0deaf046a4
diff --git a/gradlew b/gradlew
index 243699d..724283c 100755
--- a/gradlew
+++ b/gradlew
@@ -215,13 +215,22 @@
TMPDIR_ARG="-Djava.io.tmpdir=$TMPDIR"
fi
-if "$JAVACMD" "${JVM_OPTS[@]}" $TMPDIR_ARG -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain $HOME_SYSTEM_PROPERTY_ARGUMENT $TMPDIR_ARG "$XMX_ARG" "$@"; then
- exit 0
-else
- # Print AndroidX-specific help message if build fails
- # Have to do this build-failure detection in gradlew rather than in build.gradle
- # so that this message still prints even if buildSrc itself fails
- echo
- echo See also development/diagnose-build-failure for help with build failures in this project.
- exit 1
+function runGradle() {
+ if "$JAVACMD" "${JVM_OPTS[@]}" $TMPDIR_ARG -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain $HOME_SYSTEM_PROPERTY_ARGUMENT $TMPDIR_ARG "$XMX_ARG" "$@"; then
+ return 0
+ else
+ # Print AndroidX-specific help message if build fails
+ # Have to do this build-failure detection in gradlew rather than in build.gradle
+ # so that this message still prints even if buildSrc itself fails
+ echo
+ echo See also development/diagnose-build-failure for help with build failures in this project.
+ exit 1
+ fi
+}
+
+runGradle "$@"
+# Check whether we were given the "-PverifyUpToDate" argument
+if [[ " ${@} " =~ " -PverifyUpToDate " ]]; then
+ # Re-run Gradle, and verify that the tasks are up-to-date
+ runGradle "$@" -PdisallowExecution
fi