In this post we will learn how to install Gradle in OS X. The following steps will guide our installation process to make Gradle available in our OS X machine. But before we start let’s take a look at the definition from wikipedia about Gradle.
Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven of declaring the project configuration.
I. Using Homebrew
The short and simple answer is to use the Homebrew package manager for macOS. You can visit the website for detail on how to install the Homebrew. But to help you, I’ve copied the online script to install it below:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After installing Homebrew, just type the following command to install Gradle.
brew install gradle
Now, if you want to do it manually, here are the steps 😉
II. Manual Installation Steps
1. Download Gradle
To download visit Gradle Releases Page. Download the complete distribution which includes binaries, sources and offline documentation. For example, you can download the latest release of Gradle, as of this update the version is
2. Unpacking Gradle and Configure Environment Variables
- Create a new directory
sudo mkdir /usr/local/gradle.
- Extract the downloaded Gradle distribution archive by executing
sudo unzip gradle-4.0.2-all.zip -d /usr/local/gradle.
.bash_profilein your home directory to add
GRADLE_HOMEvariable with the following line
- Also update the
PATHvariable to include
$GRADLE_HOME/bin. If you don’t already have the
PATHvariable add the following line
source ~/.bash_profileto executes the update version of
.bash_profile. Or you can open a new
Terminal.appto make this changes active.
3. Running the Installation
To test Gradle installation open the
Terminal.app and execute
gradle -v command. If your installation was correct you will see something like the following output:
$ gradle -v ------------------------------------------------------------ Gradle 4.0.2 ------------------------------------------------------------ Build time: 2017-07-26 15:04:56 UTC Revision: 108c593aa7b43852f39045337ee84ee1d87c87fd Groovy: 2.4.11 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.8.0_121 (Oracle Corporation 25.121-b13) OS: Mac OS X 10.12.6 x86_64
- How do I split large excel file into multiple smaller files? - April 15, 2023
- How do I get the number of processors available to the JVM? - March 29, 2023
- How do I show Spring transaction in log / console? - March 29, 2023
brew install gradle
Absolutely, using brew package make our life a lot easier 🙂
Thanks a Lot 🙂
Thanks Wayan for such an amazing help. However I have one question.
After installation was done and when I executed the command “
gradle -v” though it showed the proper version but there was warning as well. Could you please comment on this warning (pasting it below for your reference).
I guess this issue related JDK 9. You can see it here: https://github.com/gradle/gradle/issues/3118.
Manual Installation isn’t working fine for me. I have created folder structure as it is and exported PATH as well but it isn’t working fine.
Can you share what kind of error did you get when running the steps described in the post above?
very well documented. Thanks.
Manual installation works fine and shows gradle -v detail (Gradle 5.2.1), but if i open new terminal gradle -v
-bash: gradle: command not found.
Have you update the
$PATHvariable to include the path to your Gradle installation? To make it permanent you can set it in your
Hi Wayan Saryada
I have issue with unzipping, the gradle file its in the downloads and tried the sudo unzip but it says
unzip: cannot find or open gradle-5.4.1-bin.zip, gradle-5.4.1-bin.zip.zip or gradle-5.4.1-bin.zip.ZIP.
I was facing issue setting the gradle version globally in bash_profile file, I added the export statements inside .zshrc file, it solved the issue
Wow! Thanks. Super easy to follow through and worked.