JDKs Gradle Plugin

Downloads JDK distributions.

Install

build.gradle
plugins {
    id 'org.jreleaser.jdks' version '0.9.1-SNAPSHOT'
}

Configuration DSL

JDKS must define the following properties:

  • name: a user defined name, must be unique.

  • url: the URL from where the JDK can be downloaded.

  • checksum: the checksum value used to verify the archive’s integrity.

  • platform: the platform this JDK is related to.

The checksum property accepts thew following formats:

  • <algorithm>/<checksum>

  • <checksum>

The value of <algorithm> must match those specified at MessageDigest section in the Java Security Standard Algorithm Names Specification. If no value for <algorithm> is given then SHA-256 is assumed.

The value of platform is dictated by the normalized values detected by os-maven-plugin. You may use the plain platform value or append a arch classifier. The following values are currently recognized:

platform

aix, hpux, os400, linux, linux_musl, osx, freebsd, openbsd, netbsd, sunos, windows, zos.

arch

x86_64, x86_32, itanium_64, itanium_32, sparc_32, sparc_64, arm_32, aarch64, mips_32, mipsel_32, mips_64, mipsel_64, ppc_32, ppcle_32, ppc_64, ppcle_64, s390_32, s390_64, riscv

Examples:

  • osx

  • osx-aarch64

  • windows

  • linux

  • linux-x86_64

Use linux_musl for artifacts that target Alpine Linux.

Here’s an example configuration

jdks {
    zulu11Linux {
        platform = 'linux'
        url = 'https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-linux_x64.zip'
        checksum = '9d1718ef74c29a8148b67ddd90bc9267fc1614e0a1eb0f4ea16e234e86419a60'
    }
    zulu11Windows {
        platform = 'windows'
        url = 'https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-win_x64.zip'
        checksum = '7bcbaedecca73811f70a5ee89e9258afff9bc009286449d97d9b3105f52a1a3a'
    }
    zulu11Osx {
        platform = 'osx'
        url = 'https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-macosx_x64.zip'
        checksum = 'abc3a9696fb6c10efcf3c5878cdb049244b0ba5dcc7141c6f0f88b99df626d2a'
    }
}

Tasks

The following tasks are provided per JDK

copyJdkFromCache<name>

Copies a JDK archive from the Gradle cache directory into the build directory.

deleteJdkFromCache<name>

Deletes a JDK archive from the Gradle cache directory.

downloadJdk<name>

Downloads a JDK with a matching name.

verifyJdk<name>

Verifies the integrity of the JDK archive with a matching name.

unpackJdk<name>

Unpacks the JDK archive with a matching name.

The following tasks are provided for all JDKS

deleteJdksFromCache

Deletes all cached JDKS.

downloadJdks

Downloads all configured JDKS.

verifyJdks

Verifies all configured JDKS.

unpackJdks

Unpacks all configured JDKS.

setupJdks

Downloads, verifies, and unpacks all configured JDKS.

listJdks

Lists all configured JDKS.

copyJdksToCache

Copies all JDK archives to the Gradle cache directory.

copyJdksFromCache

Copies all JDK archives from the Gradle cache directory to the build directory.

Examples

Listing all JDKS

$ gm listJdks

> Task :listJdks
== JDK zulu11Linux ==
url: https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-linux_x64.zip
checksum: 9d1718ef74c29a8148b67ddd90bc9267fc1614e0a1eb0f4ea16e234e86419a60
platform: linux

== JDK zulu11Osx ==
url: https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-macosx_x64.zip
checksum: abc3a9696fb6c10efcf3c5878cdb049244b0ba5dcc7141c6f0f88b99df626d2a
platform: osx

== JDK zulu11Windows ==
url: https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-win_x64.zip
checksum: 7bcbaedecca73811f70a5ee89e9258afff9bc009286449d97d9b3105f52a1a3a
platform: windows

Setup all JDKS

$ gm setuJdks

> Task :downloadJdkZulu11Linux
Download https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-linux_x64.zip

> Task :downloadJdkZulu11Osx
Download https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-macosx_x64.zip

> Task :downloadJdkZulu11Windows
Download https://cdn.azul.com/zulu/bin/zulu11.48.21-ca-jdk11.0.11-win_x64.zip

> Task :downloadJdks
> Task :verifyJdkZulu11Linux
> Task :unpackJdkZulu11Linux
> Task :verifyJdkZulu11Osx
> Task :unpackJdkZulu11Osx
> Task :verifyJdkZulu11Windows
> Task :unpackJdkZulu11Windows
> Task :unpackJdks
> Task :verifyJdks
> Task :setupJdks
> Task :copyJdksToCache

All tasks are added to the JDKS group

$ gm tasks --group=JDKS

> Task :tasks

------------------------------------------------------------
Tasks runnable from root project 'app'
------------------------------------------------------------

Jdks tasks
----------
copyJdkFromCacheZulu11Linux - Copy JDK zulu11Linux from cache
copyJdkFromCacheZulu11Osx - Copy JDK zulu11Osx from cache
copyJdkFromCacheZulu11Windows - Copy JDK zulu11Windows from cache
copyJdksFromCache - Copy JDKs from Gradle cache
copyJdksToCache - Copy JDKs to Gradle cache
deleteJdkFromCacheZulu11Linux - Delete JDK zulu11Linux from cache
deleteJdkFromCacheZulu11Osx - Delete JDK zulu11Osx from cache
deleteJdksFromCache - Delete JDKs from Gradle cache
downloadJdks - Download all JDKs
downloadJdkZulu11Linux - Download JDK zulu11Linux
downloadJdkZulu11Osx - Download JDK zulu11Osx
downloadJdkZulu11Windows - Download JDK zulu11Windows
listJdks - Lists all JDKs
setupJdks - Setups all JDKs
unpackJdks - Unpack all JDKs
unpackJdkZulu11Linux - Unpack JDK zulu11Linux
unpackJdkZulu11Osx - Unpack JDK zulu11Osx
unpackJdkZulu11Windows - Unpack JDK zulu11Windows
verifyJdks - Verify all JDKs
verifyJdkZulu11Linux - Verify JDK zulu11Linux
verifyJdkZulu11Osx - Verify JDK zulu11Osx
verifyJdkZulu11Windows - Verify JDK zulu11Windows