Is it possible to configure the local gradle cache folder to non-default location?


(Shlomi Hazan) #1

I want to be able to use a different folder than “~/.gradle/caches/modules-2/files-2.1” to be the local gradle cache folder.
Is it possible (without hacking the username)?

10x


(Mark Vieira) #2

You can change the directory of the entire ~/.gradle directory, also known as the “Gradle User Home” with the -g command line argument.

gradle -g /some/other/dir build

(Shlomi Hazan) #3

Hey Mark,

Thanks for answering.
As your suggestion will change the local gradle cache directory, it will probably do more than just that, right?

Just to be sure: what else will happen?
I do see the daemon also uses this “Gradle User Home” folder to store lock files, as well as code (dll) and log files.

I will explain my primary question to be clearer:
When I do a build aimed at production I would like to have the build start conditions to be completely defined,
and a cache can be tricky in this regard having whatever jars / modules / metadata as leftovers or whatever the case may be. So I am willing to pay the extra fetch of the required artifacts in order to be sure I always start from the same state and so have a better chance of getting the same result.

So while the daemon itself does not make your suggestion unacceptable, I need to know what else is affected, at least to be able to be consistent with my build procedure (assuming the wrapper using this directory as well being a non-issue for my goal).

Thank you!
Shlomi


(Mark Vieira) #4

If all you want is a totally “clean” build environment then using a unique Gradle User Home will accomplish that. It will also mean (non-exhaustive list):

  1. Previously downloaded wrappers will have to downloaded again
  2. Existing running daemons will not be used, a new daemon will be started
  3. Build scripts will be recompiled
  4. Gradle API and TestKit jars rebuilt

So in generally, we cache a bunch of different stuff in that location, not just dependency artifacts.


(Shlomi Hazan) #5

Thanks, Mark.
I will give it a try.