We can change the Gradle user home directory in several ways. Gradle uses the directory .gradle
in our home directory as the default Gradle user home directory. Here we can find for example the directory caches
with downloaded dependencies. To change the Gradle user home directory we can set the environment variable GRADLE_USER_HOME
and point it to another directory. The Gradle build script will look for this environment variable and then use the specified directory as the Gradle home directory.
$ export GRADLE_USER_HOME=/Users/mrhaki/dev/gradle $ gradle -d -r 07:36:40.020 [main] INFO org.gradle.launcher.Main - Starting Builder 07:36:40.120 [main] DEBUG org.gradle.launcher.Main - Gradle user home: /Users/mrhaki/dev/gradle ...
But this is not the only way to change the Gradle user home directory. We can also pass the Java system property gradle.user.home
to Gradle and specify a new directory. In the following sample we use the environment variable GRADLE_OPTS
to pass the Java system property, but we could also use JAVA_OPTS
.
$ export GRADLE_OPTS=-Dgradle.user.home=/Users/mrhaki/dev/gradle $ gradle -d 07:36:40.020 [main] INFO org.gradle.launcher.Main - Starting Builder 07:36:40.120 [main] DEBUG org.gradle.launcher.Main - Gradle user home: /Users/mrhaki/dev/gradle ...
Or we can use the command-line options -g
and --gradle-user-home
when we run Gradle and use a different directory as a Gradle user home directory.
$ gradle -g /Users/mrhaki/dev/gradle -d 07:36:40.020 [main] INFO org.gradle.launcher.Main - Starting Builder 07:36:40.120 [main] DEBUG org.gradle.launcher.Main - Gradle user home: /Users/mrhaki/dev/gradle ...
$ gradle --gradle-user-home=/Users/mrhaki/dev/gradle -d 07:36:40.020 [main] INFO org.gradle.launcher.Main - Starting Builder 07:36:40.120 [main] DEBUG org.gradle.launcher.Main - Gradle user home: /Users/mrhaki/dev/gradle ...
Written with Gradle 0.9.