How to install a specific Gradle version on your Mac?

I’ve recently had to install Gradle on a fresh Mac and decided to use Homebrew, as this is the package manager I use most of the time. By quickly typing brew install gradle the latest Gradle version got installed immediately, as expected. I’ve quickly realised this is not what I needed, though. What I wanted was a specific version of Gradle installed. This should be easy with Homebrew… Well, let’s go through some options we have.


Homebrew offers a capability of installing a package (aka formula) of a custom version, however in the past it required tapping homebrew/boneyard. All you have to do is to search for a package .The biggest issue is that not many packages provide formulas for older versions in the versions repository, like Gradle.

$ brew search gradle
gradle homebrew/versions/gradle214

If you are lucky enough and find a version of a formula you were looking for then you can install it by typing the entire string:

$ brew install homebrew/versions/gradle214

You will probably notice that Brew will automatically tap homebrew/versions tap. To check, which version of a formula is currently active just use the info command. You can switch between multiple versions easily as well, if necessary.

$ brew info gradle  
gradle: stable 3.3
$ brew switch gradle {version}

Unfortunately, the Gradle version I was looking for was not available within the versions repository as outlined above, so I had to look for other options.


I decided to try out SDKMAN! out, which looked very promising. I wasn’t disappointed. SDKMAN! gave me access to even more Gradle versions than I needed.

$ sdk list gradle  
Available Gradle Versions
3.4-rc-3 2.2.1 2.7

Installation of all required package versions and switchover between them was even simpler.

$ sdk install gradle 2.7
$ sdk install gradle 3.3
$ sdk use gradle 2.7

Please note that the use command does switch between candidates in the current shell. If you want to make the change permanent you must use default command instead.

$ sdk default gradle 2.7

And you are done. For more examples please refer to the SDKMAN! usage page.

I guess the conclusion is we should never stick blindly to tools we love as there are many interesting alternative to explore out there. Even though you may prefer to stay with your tool in the end you shouldn’t give up a chance of learning something new and widening your experience.

“Nothing is pleasanter to me than exploring in a library.”
—Walter Savage Landor