Set GRADLE_USER_HOME when OUT_DIR is specified.

On build server we don't want to use the default ~/.gradle/ home directory
as that get shared between beild and thus causing flakiness.

Test: OUT_DIR="../../out" ./gradlew assembleDebug
Change-Id: I02ea6228499285841848130c1405b8d4c0e049cd
diff --git a/gradlew b/gradlew
index 4c2ef38..a096da0 100755
--- a/gradlew
+++ b/gradlew
@@ -6,6 +6,14 @@
 ##
 ##############################################################################
 
+# --------- androidx specific code needed for build server. ------------------
+
+if [ -n "$OUT_DIR" ] ; then
+    export GRADLE_USER_HOME="$OUT_DIR/.gradle"
+fi
+
+# ----------------------------------------------------------------------------
+
 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 
 APP_NAME="Gradle"