Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move gradle temporary cache dir to other directory

Tags:

gradle

gradlew

I have some trouble with the temporary gradle cache directory. Gradle downloads all dependencies at first to /tmp/gradle_download...bin before it moves them to their target directory.

10:55:12.932 [DEBUG] [org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor] Downloading https://${myNexusURL}/nexus/content/groups/../myArtefact.zip to /tmp/gradle_download1430290155040442921bin

Our space on /tmp is very limited but on other directories we have enough space. Is there a way to change that directory?

./gradlew -version

------------------------------------------------------------
Gradle 3.0
------------------------------------------------------------

Build time:   2016-08-15 13:15:01 UTC
Revision:     ad76ba00f59ecb287bd3c037bd25fc3df13ca558

Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_91 (Oracle Corporation 25.91-b14)
OS:           Linux 3.0.101-0.40-default amd64

Thanks for help

like image 212
Björn P Avatar asked Jun 20 '17 09:06

Björn P


2 Answers

As mentioned by the OP in his own answer, the temporary directory used by Gradle can be set via the java.io.tmpdir system property. Maybe the following is obvious but just in case: you can also configure this system property with an environment variable for Gradle so that you don’t have to separately configure it with each Gradle call.

For example, you could add the following to your .bashrc:

export GRADLE_OPTS=-Djava.io.tmpdir=/path/to/tmpdir

GRADLE_OPTS should be recognized by both gradle and the Gradle Wrapper (gradlew).

like image 171
Chriki Avatar answered Oct 18 '22 13:10

Chriki


Solving it via -Djava.io.tmpdir=/path/to/tmpdir

like image 26
Björn P Avatar answered Oct 18 '22 12:10

Björn P