Install Groovy on macOS

Homebrew is the shortest install on macOS: it brings the JDK dependency with it and links the command into /opt/homebrew/bin on Apple silicon. This is the macOS page of the install overview.

Install with Homebrew

One command installs Groovy and the JDK it depends on:

brew install groovy

On an Intel Mac the prefix is /usr/local; on Apple silicon it is /opt/homebrew. Both are on the PATH of a normal shell, so no environment variable is needed.

Check the version

groovy --version prints the version, the JVM and the vendor. When the answer names a JVM you did not expect, /usr/libexec/java_home -V lists the JDKs macOS knows and JAVA_HOME picks one.

SDKMAN instead

SDKMAN works on macOS as on Linux and keeps several Groovy versions side by side:

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install groovy

The install downloads from the network, which this container does not have: the three commands are shown and not run. The Java install page for macOS covers the JDK in more detail.

Related

Автор статьи: Arthur Isaev