Let me explain by its code.Normally there is directory called wrapper
under gradle
. If you use JD-GUI
to read gradle-wrapper.jar
, you can find GradleUserHomeLookup.class
public class GradleUserHomeLookup{
public static final String DEFAULT_GRADLE_USER_HOME = System.getProperty("user.home") + "/.gradle";
public static final String GRADLE_USER_HOME_PROPERTY_KEY = "gradle.user.home";
public static final String GRADLE_USER_HOME_ENV_KEY = "GRADLE_USER_HOME";
public static File gradleUserHome(){
String gradleUserHome;
if ((gradleUserHome = System.getProperty("gradle.user.home")) != null) {
return new File(gradleUserHome);
}
if ((gradleUserHome = System.getenv("GRADLE_USER_HOME")) != null) {
return new File(gradleUserHome);
}
return new File(DEFAULT_GRADLE_USER_HOME);
}
}
- If
gradle.user.home
exists, it will be returned.
- If there is no
gradle.user.home
but you have set GRADLE_USER_HOME
, GRADLE_USER_HOME
will be returned
- If
gradle.user.home
and GRADLE_USER_HOME
neither exists, DEFAULT_GRADLE_USER_HOME
(Users/your-name/.gradle) will be returned.
Here is an example. In gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Notice the last line which configures gradle's version = 3.3
. In Android-Studio, gradle command is from wrapper/dists/your-version/xxxx/gradle-3.3/bin/
. If there is no version
, it will download gradle and install it in wrapper/dists/...
. More details in Install.class
.
EDIT
You can find more info here