Konstantin Ryadov JVM engineer turned AI engineer. Things I have built.

SDKMAN!: an SDK manager for Java, Groovy, Kotlin and Scala developers and their frameworks

Every developer, build engineer and plain DevOps person has to install and update the JDK, Ceylon, Groovy, Kotlin, Scala, Grails, Griffon and Spring Framework one way or another, along with the build tools that go with them: Ant, Maven, Gradle, Kobalt, sbt and the rest. http://sdkman.io/ is a Unix tool for managing different SDK versions. It also works under Cygwin on Windows.

SDKMAN!

Here is what it looks like, after running:

  1. the installer
$ curl -s "https://get.sdkman.io" | bash
  1. the command that sets up the environment:
$ source "$HOME/.sdkman/bin/sdkman-init.sh"

Installing an SDK

The latest stable version

Install the latest stable version of an SDK (the Java JDK, for example):

$ sdk install java

It will show:

                                                    
Downloading: java 8u121

In progress...

######################################################################## 100.0%

Installing: java 8u121
Done installing!

After that you can make it the default version.

Do you want java 8u121 to be set as default? (Y/n):

If you answer yes (or press enter), every shell you open will use the SDK version named above.

Setting java 8u121 as default.

A specific version

Need a specific version of an SDK? Just pass it as an argument:

$ sdk install scala 2.12.1

A local version

Need a snapshot? Already have a local installation? Install the local version:

$ sdk install groovy 3.0.0-SNAPSHOT /path/to/groovy-3.0.0-SNAPSHOT

Removing a version

Remove an installed version:

$ sdk uninstall scala 2.11.6

Listing available SDKs and other candidates

To get a list of what is available for installation:

$ sdk list

This prints an alphabetical list of candidates with a description, the latest stable version, the website and the install command.

================================================================================
Available Candidates
================================================================================
q-quit                                  /-search down
j-down                                  ?-search up
k-up                                    h-help
--------------------------------------------------------------------------------
Groovy (2.4.5)                                       http://www.groovy-lang.org/

Groovy is a powerful, optionally typed and dynamic language, with static-typing
and static compilation capabilities, for the Java platform aimed at multiplying
developers’ productivity thanks to a concise, familiar and easy to learn syntax.
It integrates smoothly with any Java program, and immediately delivers to your
application powerful features, including scripting capabilities, Domain-Specific
Language authoring, runtime and compile-time meta-programming and functional
programming.

                                                            $ sdk install groovy
--------------------------------------------------------------------------------
Scala (2.11.7)                                        http://www.scala-lang.org/
...

Listing available versions

Get the list of versions of a candidate:

$ sdk list groovy

This shows the available, local and current versions:

================================================================================
Available Groovy Versions
================================================================================
 > * 2.4.4                2.3.1                2.0.8                1.8.3
     2.4.3                2.3.0                2.0.7                1.8.2
     2.4.2                2.2.2                2.0.6                1.8.1
     2.4.1                2.2.1                2.0.5                1.8.0
     2.4.0                2.2.0                2.0.4                1.7.9
     2.3.9                2.1.9                2.0.3                1.7.8
     2.3.8                2.1.8                2.0.2                1.7.7
     2.3.7                2.1.7                2.0.1                1.7.6
     2.3.6                2.1.6                2.0.0                1.7.5
     2.3.5                2.1.5                1.8.9                1.7.4
     2.3.4                2.1.4                1.8.8                1.7.3
     2.3.3                2.1.3                1.8.7                1.7.2
     2.3.2                2.1.2                1.8.6                1.7.11
     2.3.11               2.1.1                1.8.5                1.7.10
     2.3.10               2.1.0                1.8.4                1.7.1

================================================================================
+ - local version
* - installed
> - currently in use
================================================================================

Using a version for the session

To use a particular version in the current terminal (the current session):

$ sdk use scala 2.12.1

Setting the default version

To set the default version:

$ sdk default scala 2.11.6.

Showing the current version

To see the current version of a candidate:

$ sdk current java
  Using java version 8u111

To see the current versions of all candidates:

$ sdk current
  Using:
  groovy: 2.4.7
  java: 8u111
  scala: 2.12.1

Outdated versions

To see outdated versions of a candidate:

$ sdk outdated springboot
  Outdated:
  springboot (1.2.4.RELEASE, 1.2.3.RELEASE < 1.2.5.RELEASE)

To see outdated versions of all candidates:

$ sdk outdated
  Outdated:
  gradle (2.3, 1.11, 2.4, 2.5 < 2.6)
  grails (2.5.1 < 3.0.4)
  springboot (1.2.4.RELEASE, 1.2.3.RELEASE < 1.2.5.RELEASE)

The SDKMAN! version

Show the SDKMAN! version:

$ sdk version

Release announcements

Get the list of release announcements:

$ sdk broadcast
==== BROADCAST =================================================================
* 06/12/16: Scala 2.12.1 released on SDKMAN! #scala
* 23/11/16: Gradle 3.2.1 released on SDKMAN! #gradle
* 22/11/16: Ceylon 1.3.1 released on SDKMAN! #ceylonlang
================================================================================

You will also get the announcement when a new version of a candidate comes out and you run any command. Every new announcement is also posted to Twitter.

Offline mode

SDKMAN! can work offline:

$ sdk offline enable
  Forced offline mode enabled.

$ sdk offline disable
  Online mode re-enabled!

In offline mode most commands still work. The list command, for instance, shows only the installed and the currently active versions:

$ sdk list
  ------------------------------------------------------------
  Offline Mode: only showing installed groovy versions
  ------------------------------------------------------------
   > 2.4.4
   * 2.4.3
  ------------------------------------------------------------
  * - installed
  > - currently in use
  ------------------------------------------------------------

Offline mode is also switched on and off automatically when the connection to the SDKMAN! servers is lost or comes back.

Updating SDKMAN!

You can update SDKMAN! itself:

$ sdk selfupdate

To force a reinstall:

$ sdk selfupdate force

Flush

From time to time you need to clear SDKMAN!'s caches. The flush command does that:

Candidates

$ sdk flush candidates

Clears the list of candidates. A new terminal fetches the current list and caches it again. This is usually useful when a new candidate appears in SDKMAN!.

Broadcast

$ sdk flush broadcast

Clears the announcement cache and fetches the latest announcements on the next command.

Archives

$ sdk flush archives

Clears all cached SDK archives. This can be useful for saving disk space.

Temporary files

$ sdk flush temp

Cleans up the temporary files SDKMAN! itself needs to work.

Configuration

The configuration lives in ~/.sdkman/etc/config:

# make sdkman non-interactive, preferred for CI environments
sdkman_auto_answer=true|false

# perform automatic selfupdates
sdkman_auto_selfupdate=true|false

# disables SSL certificate verification
# https://github.com/sdkman/sdkman-cli/issues/327
# HERE BE DRAGONS....
sdkman_insecure_ssl=true|false

# disable GVM alias, for users of the Go Version Manager
sdkman_disable_gvm_alias=true|false

# configure curl timeouts
sdkman_curl_connect_timeout=5
sdkman_curl_max_time=4

# subscribe to the beta channel
sdkman_beta_channel=true

Originally published in Russian on LiveJournal.

All posts