41 lines
1.4 KiB
Markdown
41 lines
1.4 KiB
Markdown
|
# JLink Gradle plugin
|
||
|
|
||
|
This project defines a Gradle plugin that enable the use of
|
||
|
[jlink](https://docs.oracle.com/javase/9/tools/jlink.htm) in Gradle builds.
|
||
|
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.
|
||
|
|
||
|
## Jlink plugin usage
|
||
|
|
||
|
This Gradle plugin integrates with the [Gradle Java Library plugin](https://docs.gradle.org/current/userguide/java_library_plugin.html)
|
||
|
to create distributions automatically using a jlink runtime rather than a user provided JDK runtime.
|
||
|
|
||
|
It applies the `org.xbib.gradle.plugin.jlink` plugin which configures a `jlink` task that executes the jlink tool.
|
||
|
|
||
|
```groovy
|
||
|
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.
|