gradlew offering a "--clean" argument to replace cleanBuild.sh

to make it easier to add "--clean" into an invocation of a busytown script

Bug: 145985767
Test: ./busytown/androidx.sh --clean # and see the message about cleaning caches
Test: ./gradlew projects && ./gradlew projects # and see that the second invocation is fast
Test: ./gradlew projects --clean # and see the message about gradlew removing caches
Test: ./cleanBuild.sh -y projects # and see the message about gradlew removing caches
Test: ./gradlew projects --ci # and see that gradlew prints that it is expanding '--ci'
Test: mkdir -p ~/.gradle && touch ~/.gradle/test && ./gradlew projects --clean # and see that ~/.gradle/test was deleted

Change-Id: I62f82533b85518711bd334a95cb0503d89f84bf6
diff --git a/cleanBuild.sh b/cleanBuild.sh
index 3ee4ae6..c6ed4dd 100755
--- a/cleanBuild.sh
+++ b/cleanBuild.sh
@@ -1,19 +1,6 @@
 #!/bin/bash
 set -e
 
-echo "IF THIS SCRIPT FIXES YOUR BUILD; OPEN A BUG."
-echo "In nearly all cases, it should not be necessary to run a clean build."
-echo
-echo "You may be more interested in running:"
-echo
-echo "  ./development/diagnose-build-failure/diagnose-build-failure.sh $*"
-echo
-echo "which attempts to diagnose more details about build failures"
-# one case where it is convenient to have a clean build is for double-checking that a build failure isn't due to an incremental build failure
-# another case where it is convenient to have a clean build is for performance testing
-# another case where it is convenient to have a clean build is when you're modifying the build and may have introduced some errors but haven't shared your changes yet (at which point you should have fixed the errors)
-echo
-
 DO_PROMPT=true
 if [ "$1" == "-y" ]; then
   DO_PROMPT=false
@@ -52,7 +39,7 @@
   # Confirm whether the user wants to run this script instead of diagnose-build-failure.sh
   # Recall that we already mentioned the existence of diagnose-build-failure.sh above
   echo
-  echo "Press <Enter> to run a clean build or Ctrl-C to cancel"
+  echo "Press <Enter> to run a clean build (./gradlew --clean $goals) or Ctrl-C to cancel"
   if [ "$DO_PROMPT" == "true" ]; then
     read response
   fi
@@ -62,25 +49,5 @@
 scriptDir="$(cd $(dirname $0) && pwd)"
 checkoutDir="$(cd $scriptDir/../.. && pwd)"
 export OUT_DIR="$checkoutDir/out"
-function removeCaches() {
-  echo removing caches
-  rm -rf .gradle
-  rm -rf buildSrc/.gradle
-  rm -f local.properties
-  # We move the Gradle cache (via the OUT_DIR) variable during this build to prevent
-  # Other Gradle builds in other directories from sharing it, to be extra-sure that the
-  # build will be clean. However, if the user subsequently runs `./gradlew`, it will use
-  # ~/.gradle as the Gradle cache dir, which could surprise users because it might hold
-  # different state. So, we preemptively remove ~/.gradle too, just in case the user
-  # is going to want that for their following build
-  rm -rf ~/.gradle
-  # AGP should (also) do this automatically (b/170640263)
-  rm -rf appsearch/appsearch/.cxx
-  rm -rf appsearch/local-backend/.cxx
-  rm -rf appsearch/local-storage/.cxx
-  rm -rf $OUT_DIR
-}
-removeCaches
 
-echo running build
-./gradlew --no-daemon $goals
+./gradlew --clean $goals