Dims
Dims

Reputation: 51049

How to set gradle cache location?

I see the following info in Eclipse package explorer:

enter image description here

Is it possible to change this location?

Upvotes: 48

Views: 71660

Answers (5)

Don Smith
Don Smith

Reputation: 553

What worked for me was to edit my Windows environment variables and add variable GRADLE_USER_HOME with value d:/.gradle. (Replace "d:/.gradle" with the path to your gradle home.) Then exit and restart Eclipse.

Upvotes: 5

Alex Cohn
Alex Cohn

Reputation: 57163

You can change the cache location since gradle 3.5. This is controlled in settings.gradle file for your project:

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

thanks to Hubert Klein Ikkink, a.k.a. mrhaki.

Upvotes: 15

Zack
Zack

Reputation: 51

You can change the location of gradle cache location in eclipse by setting the eclipse gradle preference

In Eclipse open, window-> preferences Search for 'Gradle' set 'Gradle User Home' to your preferred location Click Apply/ok

Now for the changes to take effect, you might have to do Gradle-> Refresh Gradle Project

Upvotes: 5

Andreas Schmid
Andreas Schmid

Reputation: 1215

Globally you can set

[...] Gradle user home directory (defined by the “GRADLE_USER_HOME” environment variable, which [...] defaults to USER_HOME/.gradle) [...]

See also https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties.

Otherwise for every build manually:

-g, --gradle-user-home Specifies the Gradle user home directory. The default is the .gradle directory in the user's home directory.

See https://gradle.org/docs/current/userguide/gradle_command_line.html.

Upvotes: 69

Mark Vieira
Mark Vieira

Reputation: 13466

You can't change the location of the cache specifically, but you can change the Gradle user home directory (the .gradle directory) which the cache is located in by using the -g command line argument.

Upvotes: 2

Related Questions