gradle-plugins/gradle-plugin-jlink
2024-11-07 17:48:36 +01:00
..
src more options and extension for jmod command 2024-11-07 17:48:36 +01:00
build.gradle first jmod/jlink Hello world project, successful test 2024-10-30 17:42:21 +01:00
README.md more options and extension for jmod command 2024-11-07 17:48:36 +01:00

JLink Gradle plugin

This project defines a Gradle plugin that enable the use of jmod, jdeps, jlink and jpackage and in Gradle builds on Linux.

In general, the plugin enables developers to create Java Runtimes with jlink. It uses the java toolchain to locate the jlink executable and creates a java runtime for your module path based Java application. This modularization allows small, secure and tailored application distributions.

Plugin usage

This Gradle plugin integrates with the Gradle Java Library plugin to create distributions automatically using a modular runtime rather than a user provided JDK runtime.

For this, it runs jmod, jdeps, jlink or jpackage in order to check and very module dependencies on the Gradle runtime dependencies in an automatic way with minimum parameters to specify

jmod downloads all runtime depency jars and transforms them into the jmod file specification, so jdeps

jlink creates a directory with a modular runtime (which can be passed to container builds) while jpackage relies on Linux packaging tools to create an RPM or DEB package for distribution.

Here is a minimal example to build a

plugins {
  id 'org.xbib.gradle.plugin.jlink' version "8.8.0"
}

java {
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(21))
  }
}

jlink {
  modules.set(List.of("org.example.app"))
  launcher.set("app=org.example.app/org.example.app.Main")
  stripDebug.set(true)
}

In addition, the plugin configures a jmod task to download the dependent artifacts on the runtime class path and create jmod files for the jlink task. Also, a jdeps task is automatically configured to show the dependent modules.

The plugin is currently only available under Linux.