Kevan Ahlquist
Kevan Ahlquist

Reputation: 5533

Gradle downloads to ?/.gradle directory when running tasks

Gradle created a ?/.gradle/ in the directory that gradle was run in. We would expect the cache directory to be created at ~/.gradle.

Example:

/project           # Project root and cwd when running gradle command
    /.gradle       # Expected - project-specific gradle folder
    /?             # Directory literally named with a question mark
        /.gradle   # Unexpected - Global gradle folder with wrappers and cached artifacts

Upvotes: 3

Views: 1170

Answers (3)

Mr. C
Mr. C

Reputation: 568

let's find it out why it behaves like this.
As gradle use following code to get user home:
System.getProperty("user.home"); Follow the link for openjdk 8 source code. It comes to conclusion: When JVM can not found user name in os, it will use ? as a return. So gradle will create ?/.gradle for usage.

Upvotes: 2

Kevan Ahlquist
Kevan Ahlquist

Reputation: 5533

The user running the scripts did not have a home directory, giving the user a home directory or specifying a gradle-user-home solved the issue:

gradle --gradle-user-home=/foo/bar ...

or

GRADLE_USER_HOME=/foo/bar gradle ...

Upvotes: 3

Rene Groeschke
Rene Groeschke

Reputation: 28653

There are two different folders gradle stores information. ~/.gradle is used to store downloaded artifacts, gradle wrappers, etc. Basically everything that can be shared between multiple builds. The .gradle folder in your project is used to store project specific information used for example by the gradle up-to-date check mechanism.

Upvotes: 1

Related Questions