Installing Gradle in Mac OS X

Introduction

This is a quick guide to install gradle on your macbook. Two methods are discussed here and you can follow anyone based on your requirements.

Method 1: Automatic installation

  1. Open terminal app.
  2. type brew install gradle
  3. verify using gradle -v

This is the simplest way to install gradle in your mac or any software for that matter but please note that the available version is mostly behind the latest release.

If you want to add the most recent version of gradle, which may be required for you due to specific project needs, please use the method below.

Method 2: Manual setup

  1. Download the latest version from the Gradle official web-site.
  2. Open Terminal.app.
  3. Create a new directory sudo mkdir /usr/local/gradle.
  4. Extract the downloaded Gradle distribution archive by executing sudo unzip gradle-4.2-all.zip -d /usr/local/gradle.
  5. Edit .bash_profile in your home directory to add GRADLE_HOME variable with the following line export GRADLE_HOME=/usr/local/gradle/gradle-4.2                              If you are not sure where is your .bash_profile, just do:
    cd ~
    vi .bash_profile
    This should open your .bash_profile file. You can now follow the remaining steps                below.
  6. Also update the PATH variable to include $GRADLE_HOME/bin. If you don’t already have the PATH variable add the following line export PATH=$GRADLE_HOME/bin:$PATH
  7. Run source ~/.bash_profile to executes the update version of .bash_profile. Or you can open a new Terminal.app to make this changes active.
  8. Run gradle -v