Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle.user.home - set in gradle.properties, build.gradle, or settings.gradle to a project-relative location?

Tags:

gradle

By default, gradle.user.home is set to ~/.gradle - I'd like to change it to a directory relative to the project, rather than the developer's home directory.

I know you can do so when you invoke gradle, like so:

$ gradle --gradle-user-home=./project-relative-directory

Or

$ gradle -Dgradle.user.home=./project-relative-directory

I know you can change the location of the build cache by adding the following to settings.gradle:

buildCache {
    local {
        // Set local build cache directory.
        directory = "${settingsDir}/build-cache"
    }
}

But gradle continues to use gradle.user.home for other caching.

The manual claims that you can specify gradle.user.home in gradle.properties, like so:

systemProp.gradle.user.home=./project-relative-directory

But this doesn't appear to work at all, not for absolute paths or relative paths; although it may be retrieved later via System.get, gradle doesn't appear to make use of it.

Are there any other solutions?

like image 410
drew Avatar asked Oct 26 '25 00:10

drew


1 Answers

you can also do it by changing the GRADLE_USER_HOME env variable. In this case all files will be saved in the specified directory.

export GRADLE_USER_HOME=./project-relative-directory
like image 179
Nazar Avatar answered Oct 27 '25 16:10

Nazar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!