Do we really need GRADLE_HOME? (docs/site inconsistency)


(Andrii) #1

Somehow Step 3. Configure your system environment part of the Installation page does not fully agree with 3.4. Environment variables part of The Gradle User Manual/Guide: the later says one should set GRADLE_HOME, while the former doesn’t even mention such an environment variable.
Is GRADLE_HOME some kind of legacy thing that is no longer needed?
Can you please hint on what are the likely outcomes of it (not) being set?

p.s. Another minor inconsistency is that the User Guide is called “User Manual” on the Documentation page, but seems to be referred to as “User Guide” everywhere else.


(James Justinic) #2

Both pages are saying that if you wish to install Gradle, you need to add the bin directory with the gradle binary to your PATH. This is for your OS to find the right executable when you type gradle at the command line, not Gradle.

These following two examples are identical in function. You can set GRADLE_HOME to the path of the Gradle distribution (ex: /opt/gradle/gradle-3.4) and then add $GRADLE_HOME/bin to your PATH:

GRADLE_HOME=/opt/gradle/gradle-3.4
export PATH=$PATH:$GRADLE_HOME/bin

However, you can also just hardcode the the entire path to the bin folder (ex: /opt/gradle/gradle-3.4/bin) when you add it to the path:

export PATH=$PATH:/opt/gradle/gradle-3.4/bin

Whether or not you hard code the whole path in your PATH or use an intermediate variable is really a personal preference.

P.S. Speaking of inconsistencies, your subject which references GROOVY_HOME is also inconsistent with your message that asks about GRADLE_HOME. :slight_smile:


(Andrii) #3

So, you’re saying Gradle actually never uses GRADLE_HOME? I guess it’s worth mentioning in the doc.

Thanks, I’ve just fixed it.


(James Justinic) #4

Correct, Gradle doesn’t use the GRADLE_HOME environment variable. There is a similar concept of gradleHomeDir in the API, but this is the location of the distribution running the build. This would be the same path as GRADLE_HOME if you’ve installed Gradle as listed in Chapter 3 of the User Guide, but there’s really no relationship unless you’ve created it yourself in setting PATH.

Just as many Java tools use JAVA_HOME to help locate a JDK/JRE, there might be a tool out there that depends on GRADLE_HOME being set to help find your Gradle install, but this should be a rarity given the predominance of the wrapper and that PATH is usually searched as well. This is besides the point though because it would be affecting that tool, not the function of Gradle itself.

There are a few environment variables that Gradle does read (including GRADLE_USER_HOME), which are detailed in the Build Environment section of the User Guide.