Change gradlew to place cache in android out dir.

Change-Id: Idfda9f03b297699c3b378c0fdfacc62fde1f5acf
diff --git a/gradlew b/gradlew
index f0192c9..4b67d3b 100755
--- a/gradlew
+++ b/gradlew
@@ -162,10 +162,15 @@
 JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
 
 # Change the project's .gradle to the android out dir.
+ANDROID_GRADLE_ROOT="$APP_HOME/../../out/host/gradle/tools/build"
 if [[ -z "$ANDROID_CACHE_DIR" ]]; then
-  ANDROID_CACHE_DIR="$APP_HOME/../../out/host/gradle/tools/build/.gradle"
+  ANDROID_CACHE_DIR="$ANDROID_GRADLE_ROOT/.gradle"
 fi
 
+# Change the local user directories to be under the android out dir
+export GRADLE_USER_HOME="$ANDROID_GRADLE_ROOT/.gradle"
+export M2_HOME="$ANDROID_GRADLE_ROOT/.m2"
+
 exec "$JAVACMD" "${JVM_OPTS[@]}" \
     -classpath "$CLASSPATH" \
     org.gradle.wrapper.GradleWrapperMain \