240

How do I install/upgrade gradle for Mac?

Siddharth
  • 9,349
  • 16
  • 86
  • 148
mllm
  • 17,068
  • 15
  • 53
  • 64

5 Answers5

468

As mentioned in this tutorial, it's as simple as:

To install

brew install gradle

To upgrade

brew upgrade gradle

(using Homebrew of course)

Also see (finally) updated docs.

starball
  • 20,030
  • 7
  • 43
  • 238
mllm
  • 17,068
  • 15
  • 53
  • 64
  • Note the official guide: https://docs.gradle.org/current/userguide/installation.html which is frankly quite complicated... – mllm Jul 13 '15 at 14:51
  • I received following error while installing gradle using brew - Error: parent directory is world writable but not sticky. _Please report this bug:_ https://git.io/brew-troubleshooting – Andy Nov 12 '15 at 00:48
  • 2
    Works like a charm on **OS X 10.11.5** – realPK Jul 25 '16 at 04:02
  • 1
    Works well on OSX 10.13 (17A405) – Chen Oct 30 '17 at 21:19
  • 1
    In case you don't have admin rights, follow [this tutorial](https://discourse.brew.sh/t/solution-for-homebrew-user-without-admin-privileges-in-urs-local/782), replacing `walkloud` with your user name – crusy Nov 14 '17 at 20:03
  • 2
    As mentioned by ThomasW bellow, if you like flexibility and simplicity, sdkman is the way to go – ChaudPain Apr 18 '19 at 16:01
  • symlink: `/usr/local/bin/gradle`. original installed path: `/usr/local/Cellar/gradle/6.7.1/bin/gradle`. – Dr.jacky Nov 22 '20 at 11:45
  • Another way to install a specific version of Gradle is by using SDK Man. https://sdkman.io/install. after that check this answer it solved my prob. https://stackoverflow.com/a/63995156/8390144 – Shrikant Phadke Aug 04 '21 at 09:26
  • If there is an older version of gradle already installed, remember to run `brew link --overwrite gradle` – Miquel Mar 02 '23 at 00:08
29

Another alternative is to use sdkman. An advantage of sdkman over brew is that many versions of gradle are supported. (brew only supports the latest version and 2.14.) To install sdkman execute:

curl -s "https://get.sdkman.io" | bash

Then follow the instructions. Go here for more installation information. Once sdkman is installed use the command:

sdk install gradle

Or to install a specific version:

sdk install gradle 2.2

Or use to use a specific installed version:

sdk use gradle 2.2

To see which versions are installed and available:

sdk list gradle

For more information go here.

ThomasW
  • 16,981
  • 4
  • 79
  • 106
20

And using ports:

port install gradle

Ports , tested on El Capitan

Robert Gabriel
  • 1,151
  • 12
  • 24
20

I had downloaded it from http://gradle.org/gradle-download/. I use Homebrew, but I missed installing gradle using it.

To save some MBs by downloading it over again using Homebrew, I symlinked the gradle binary from the downloaded (and extracted) zip archive in the /usr/local/bin/. This is the same place where Homebrew symlinks all other binaries.

cd /usr/local/bin/
ln -s ~/Downloads/gradle-2.12/bin/gradle

Now check whether it works or not:

gradle -v
Vishal
  • 2,161
  • 14
  • 25
9

Two Method

  • using homebrew auto install:
    • Steps:
      • brew install gradle
    • Pros and cons
      • Pros: easy
      • Cons: (probably) not latest version
  • manually install (for latest version):
    • Pros and cons
      • Pros: use your expected any (or latest) version
      • Cons: need self to do it
    • Steps
      • download latest version binary (gradle-6.0.1) from Gradle | Releases
      • unzip it (gradle-6.0.1-all.zip) and added gradle path into environment variable PATH
        • normally is edit and add following config into your startup script( ~/.bashrc or ~/.zshrc etc.):
export GRADLE_HOME=/path_to_your_gradle/gradle-6.0.1
export PATH=$GRADLE_HOME/bin:$PATH

some other basic note

Q: How to make PATH take effect immediately?

A: use source:

source ~/.bashrc

it will make/execute your .bashrc, so make PATH become your expected latest values, which include your added gradle path.

Q: How to check PATH is really take effect/working now?

A: use echo to see your added path in indeed in your PATH

➜  ~ echo $PATH
xxx:/Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin:xxx

you can see we added /Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin into your PATH

Q: How to verify gradle is installed correctly on my Mac ?

A: use which to make sure can find gradle

➜  ~ which gradle
/Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin/gradle

AND to check and see gradle version

➜  ~ gradle --version

------------------------------------------------------------
Gradle 6.0.1
------------------------------------------------------------

Build time:   2019-11-18 20:25:01 UTC
Revision:     fad121066a68c4701acd362daf4287a7c309a0f5

Kotlin:       1.3.50
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          1.8.0_112 (Oracle Corporation 25.112-b16)
OS:           Mac OS X 10.14.6 x86_64

this means the (latest) gradle is correctly installed on your mac ^_^.

for more detail please refer my (Chinese) post 【已解决】mac中安装maven

crifan
  • 12,947
  • 1
  • 71
  • 56