How to Install Gradle on Mac

Gradle is a popular build automation tool primarily used for Java projects, but it supports many other languages and platforms. This guide will walk you through the steps to install Gradle on a Mac, set up the necessary environment variables, and verify the installation.

Step 1: Install Homebrew (If Not Already Installed)

Homebrew is a package manager for macOS that simplifies the installation of software. If you don't already have Homebrew installed, follow these steps:

  1. Open the Terminal application.

  2. Install Homebrew by running the following command:

    /bin/bash -c "$(curl -fsSL"
  3. Follow the on-screen instructions to complete the installation.

Step 2: Install Gradle Using Homebrew

  1. Open the Terminal application.

  2. Update Homebrew to ensure you have the latest package information:

    brew update
  3. Install Gradle by running the following command:

    brew install gradle

Homebrew will download and install Gradle, along with any dependencies.

Step 3: Verify the Installation

  1. Once the installation is complete, verify that Gradle is installed correctly by checking the version:

    gradle -v
  2. You should see an output that displays the Gradle version and other related information, indicating that Gradle is successfully installed. The output should look something like this:

Gradle 7.x.x

Build time:   yyyy-MM-dd HH:mm:ss UTC
Revision:     xxxxxxxxxxxxxxxxxxxxxx

Kotlin:       1.x.x
Groovy:       3.x.x
Ant:          Apache Ant(x.x.x)
JVM:          x.x.x (Oracle Corporation x.x.x)
OS:           Mac OS X x.x.x x86_64

Step 4: Configure Environment Variables (Optional)

By default, Homebrew sets up the necessary environment variables for Gradle. However, if you need to configure or update environment variables manually, follow these steps:

  1. Open the Terminal application.

  2. Open your shell profile file in a text editor. Depending on your shell, this might be .bash_profile, .zshrc, or another file. For example, if you use Zsh:

    nano ~/.zshrc
  3. Add the following lines to set the GRADLE_HOME environment variable and update the PATH:

    export GRADLE_HOME=/usr/local/opt/gradle/libexec
    export PATH=$PATH:$GRADLE_HOME/bin
  4. Save the file and exit the text editor.

  5. Reload the shell configuration by running:

    source ~/.zshrc


You have now successfully installed Gradle on your Mac. With Gradle installed, you can start building and managing your projects more efficiently. For more information on using Gradle, check out the official Gradle documentation.

If you encounter any issues or have any questions, feel free to ask in the comments below. Happy building!