arrow-rightgithublinkedinscroll-to-topzig-zag

Install Gradle and configure $GRADLE_HOME on a Mac

Last Updated On

Requisition:

Gradle requires Java version 7 or higher to be installed on your machine. To check it, run:

$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Install Gradle

In this example I would use Homebrew. To install Gradle using Homebrew run:

$ brew update && brew install gradle

Configure $GRADLE_HOME

In your .bash_profile file (usually located in the user's home directory) add the following line to update PATH variable:

...
export GRADLE_HOME=/usr/local/opt/gradle/libexec
export PATH=$GRADLE_HOME/bin:$PATH

Save the file. Right now, it's time to tell our environment to use changed .bash_profile by running the following command:

$ source .bash_profile

Verify the installation:

$gradle -v

------------------------------------------------------------
Gradle 4.1
------------------------------------------------------------

Build time: 'Your build time'
Revision: 941559e020f6c357ebb08d5c67acdb858a3defc2

Groovy: 2.4.11
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_131 (Oracle Corporation 25.131-b11)
OS: Mac OS X 10.12.6 x86_64

Conclusion

Right now gradle should be automatically picked up and imported by your IDE's and editors. You can also get additional information of your gradle package using

brew info gradle