.. | ||
src | ||
build.gradle | ||
README.md |
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.