Thursday, March 3, 2022

DiscoCLI

 Aloha,

As some of you might know I've created the so called DiscoAPI for foojay.io. This api should help you to get an OpenJDK distribution of your choice. In addition to the api itself I've also created different plugins for IDE's and browsers and also some tools like JDKMon.

That's all good stuff but I was always missing a command line tool which enables me to simply download an OpenJDK package of my choice in the terminal. Thank god there is Picocli which makes it possible to create a command line interface using Java.

If you use Picocli in combination with GraalVM's native image feature you can create a single binary which was exactly what I was looking for.

And even better...you can build the binaries for x64 based platforms easily using github actions.

Long story short, I've created the Disco Command Line Client or short DiscoCLI which makes it easy to download an OpenJDK distribution of your choice.


Here are some examples on how to use it:

Get Zulu with version 17.0.2 for the current operating system including JavaFX:

discocli -d zulu -v 17.0.2 -fx


Get the latest version of JDK 16 for Liberica on Windows:

discocli -d liberica -v 16 -os windows -latest


Get the JDK 17.0.2 of temurin for macos with aarch64 as a tar.gz and store it to a folder

discocli -d temurin -v 17.0.2 -os macos -arc aarch64 -at tar.gz -p /Users/hansolo


In case a JDK pkg cannot be found discocli will try to give you the available pkgs.

discocli -d liberica -v 12 -os linux -arc x64 -fx -latest

Sorry, defined pkg not found in Disco API

Packages available for Liberica for version 12:
discocli -d liberica -v 12.0.2 -os linux -lc glibc -arc amd64 -at tar.gz -pt jdk
discocli -d liberica -v 12.0.1 -os linux -lc glibc -arc amd64 -at tar.gz -pt jdk
discocli -d liberica -v 12 -os linux -lc glibc -arc amd64 -at tar.gz -pt jdk

It's also possible to simply check what packages are available for given set of parameters. If we would like
to know what packages are available of Zulu for Macos on aarch64 that come as tar.gz and offer a jdk for 
version 17.0.2, we could type the following:

discocli -f -d zulu -v 17.0.2 -os macos -arc aarch64 -pt jdk -at tar.gz

Packages found for Zulu for version 17:
discocli -d zulu -v 17.0.2 -os macos -lc libc -arc x64 -at tar.gz -pt jdk -fx
discocli -d zulu -v 17.0.2 -os macos -lc libc -arc x64 -at tar.gz -pt jdk

As always the code is available on github if you would like to build it yourself but if you simply would
like to download the binary, feel free to get it from the github releases.
I provide binaries for the following platforms:
- Macos x64 (but this also works on M1 chips because of Rosetta 2)
- Linux x64
- Linux aarch64
- Windows x64

For those of you that are asking themselves if this is not the same as SDKMan? No, it's not, SDKMan is much more
than this. DiscoCLI really only helps you downloading an OpenJDK distribution and that's it, no installation 
and nothing else than OpenJDK distributions. 
And in the near future DiscoCLI might also be available via SDKMan using JReleaser... :)

That's it for today...so keep coding... :)

No comments:

Post a Comment