- Download a binary distribution (usually packaged as a ZIP file) from the official download page.
- Unzip the distribution anywhere on your system.
- Configure environment variables.
- Get ready to go!
You must perform these steps every single time a new version comes out if you want to keep your toolbox up to date. There’s bound to be a better way to execute these repetitive tasks. This is where a package manager comes in. You will find many of them targeting a particular platform such as Homebrew, Macports, Fink (OSX), apt-get (Debian based Linux distributions), RPM (RH based Linux distributions), etc. But there’s one package manager that can target any POSIX compatible platform: SDKMAN!
SDKMAN! appeared as a Groovy related tool (previously known as GVM, short for Groovy enVironment Manager) which one would use to install Groovy, Grails, Gradle, and Griffon. The author (Marco Vermeulen @marc0der) envisioned a different version of the tool that would allow developers to install additional JVM, non-Groovy specific command-line projects, such as Scala’s SBT, Pivotal’s Spring Boot, and others. After some months of intensive work SDKMAN! (short for SDK MANanager) emerged. Getting SDKMAN! installed on your system is as easy as invoking the following command on your command prompt
$ curl -s "https://get.sdkman.io" | bash
If you happen to be on Windows I’d recommend you to have a look at Babun Shell, a much powerful version of Cygwin. Once installed you can verify that SDKMAN! is working by invoking the following command
$ sdk version SDKMAN 5.5.9+231
The command should print out the version of SDKMAN! you currently have installed. You can follow it up by asking SDKMAN! to tell you what commands are now available to you
$ sdk help Usage: sdk <command> [candidate] [version] sdk offline <enable|disable> commands: install or i <candidate> [version] uninstall or rm <candidate> <version> list or ls [candidate] use or u <candidate> [version] default or d <candidate> [version] current or c [candidate] upgrade or ug [candidate] version or v broadcast or b help or h offline [enable|disable] selfupdate [force] flush <candidates|broadcast|archives|temp> candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc. use list command for comprehensive list of candidates eg: $ sdk list version : where optional, defaults to latest stable if not provided eg: $ sdk install groovy
In SDKMAN!’s terms you work with candidates. A candidate is a project that can be installed and managed on your system, such as Maven or Gradle. If I type sdk list gradle on my computer I get the following output
$ sdk list gradle ================================================================================ Available Gradle Versions ================================================================================ * 4.0.1 3.3 2.14 1.12 4.0-rc-3 3.2.1 2.13 1.11 4.0-rc-2 3.2 2.12 1.10 4.0-rc-1 3.1 2.11 1.1 > * 4.0 3.0 2.10 1.0 3.5.1 2.9 2.1 0.9.2 3.5-rc-3 2.8 2.0 0.9.1 3.5-rc-2 2.7 1.9 0.9 3.5-rc-1 2.6 1.8 0.8 * 3.5 2.5 1.7 0.7 * 3.4.1 2.4 1.6 3.4-rc-3 2.3 1.5 3.4-rc-2 2.2.1 1.4 3.4-rc-1 2.2 1.3 * 3.4 2.14.1 1.2 ================================================================================ + - local version * - installed > - currently in use ================================================================================
The list shows all available versions of Gradle at my disposal, both locally and remotely. It looks like I have 5 versions installed on my computer and version 4.0 is the current default. Hmm but that’s not the latest version, it should be 4.0.1. Upgrading to this version is as easy as invoking
$ sdk use gradle 4.0.1 Using gradle version 4.0.1 in this shell.
Pay close attention to the print out. It explicitly indicates that version 4.0.1 is used on the current command prompt I’m using. This means that I can switch to a different command prompt and use a totally different version of Gradle. If you want to make a particular version the default one simply invoke the default command, such as
$ sdk default gradle 4.0.1 Default gradle version set to 4.0.1
There’s more to SDKMAN! that what we’ve seen so far. The server side component exposes an API that lets vendors push notifications when a new release is available, streamlining the delivery process to everyone that uses SDKMAN! You can also install popular alternative JVM languages other than Groovy, such as Scala, Kotlin, and Ceylon. I must confess I’m quite happy using SDKMAN! since it came out as GVM, is a nifty tool that deserves a place in your development toolbox.