= JDKs Gradle Plugin

Downloads JDK distributions.

== Install

[source,groovy]
[subs="attributes"]
.build.gradle
----
plugins {
    id 'org.jreleaser.jdks' version '{jreleaser-version}'
}
----

== 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
link:https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#messagedigest-algorithms[MessageDigest section]
in the Java Security Standard Algorithm Names Specification. If no value for `<algorithm>` is given then `SHA-256` is assumed.

include::configuration:partial$platform.adoc[]

Here's an example configuration

[source,groovy]
[subs="attributes"]
----
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'
    }
    graal21_1_0_linux {
        platform = 'linux'
        url = 'https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz'
        checksum = '39252954d2cb16dbc8ce4269f8b93a326a0efffdce04625615e827fe5b5e4ab7'
    }
}
----

== Tasks

The following tasks are provided per JDK

=== downloadJdk<name>

Downloads a JDK with a matching name.

=== verifyJdk<name>

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


=== downloadJdk<name>

Unpacks the JDK archive with a matching name.

The following tasks are provided for all 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

[source]
----
$ gm listJdks

> Task :listJdks
== JDK graal21_1_0_linux ==
url: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz
checksum: 39252954d2cb16dbc8ce4269f8b93a326a0efffdce04625615e827fe5b5e4ab7
platform: linux

== 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

[source]
----
$ gm setuJdks

> Task :downloadJdkGraal21_1_0_linux
Download https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.1.0/graalvm-ce-java11-linux-amd64-21.1.0.tar.gz

> 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 :verifyJdkGraal21_1_0_linux
> Task :unpackJdkGraal21_1_0_linux
> 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

[source]
----
$ gm tasks --group=JDKS

> Task :tasks

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

Jdks tasks
----------
copyJdksFromCache - Copy JDKs from Gradle cache
copyJdksToCache - Copy JDKs to Gradle cache
downloadJdkGraal21_1_0_linux - Download JDK graal21_1_0_linux
downloadJdks - Download all JDKs
downloadJdkZulu11Linux - Download JDK zulu11Linux
downloadJdkZulu11Osx - Download JDK zulu11Osx
downloadJdkZulu11Windows - Download JDK zulu11Windows
listJdks - Lists all JDKs
setupJdks - Setups all JDKs
unpackJdkGraal21_1_0_linux - Unpack JDK graal21_1_0_linux
unpackJdks - Unpack all JDKs
unpackJdkZulu11Linux - Unpack JDK zulu11Linux
unpackJdkZulu11Osx - Unpack JDK zulu11Osx
unpackJdkZulu11Windows - Unpack JDK zulu11Windows
verifyJdkGraal21_1_0_linux - Verify JDK graal21_1_0_linux
verifyJdks - Verify all JDKs
verifyJdkZulu11Linux - Verify JDK zulu11Linux
verifyJdkZulu11Osx - Verify JDK zulu11Osx
verifyJdkZulu11Windows - Verify JDK zulu11Windows
----

