JLink-JPackager Maven Plugin

The JLink-JPackager Maven Plugin is intended to create Modular Java Run-Time Images via jlink with JDK 9 and above or native installable packages via jpackage with JDK 14 and above.

Although the jlink and jpackage tools have some limitations in regards to using non module jars and automatic module jars the JLink-JPackager Maven Plugin can create ZIP files for Modular Java Run-Time Images or package installers with Java Runtimes and mixed real and automatic modules and non modular jars.

It does this by analyzing java module dependencies of all maven dependencies using the jdeps java tool and modifying command line parameters for the jlink the jpackage and the java executable based on the findings.

The resulting Java Runtime contains all java system module dependencies of all real modules, all automatic modules and all non-modular JAR files which are put on the classpath.

NOTE: This is an alpha release which means everything can change until we reach the first milestone release.

The JLink-JPackager Maven Plugin is available on GitHub: jlink-jpackager-maven-plugin

It is based on the Apache maven-jlink-plugin

The intended artifacts to be linked together into a Modular Run-Time Image are the jmod and jar files. JMod files can be created by using the Maven JMod Plugin and jar files can be created by using the Maven JAR Plugin.

Goals Overview

The JLink-JPackager Maven Plugin has six goals:

Usage

General instructions on how to use the JLink-JPackager Plugin can be found on the usage page. Some more specific use cases are described in the examples given below.

Usually you will use the Maven JLink-JPackager Maven Plugin to create a Run Time Image or an installable Package from one or more modules within a multi module build.

You will than use one submodule there with a pom.xml which uses one of the special Maven packaging types the plugin provides and a configuration for the plugin.

In other words it is not possible to create a Run Time Image or Installation Package from a single Maven Project within the same single Maven Project and you usually would not call the goals of the plugin by using a plugin execution configuration.

Examples

To provide you with better understanding on some usages of the JLink-JPackager Maven Plugin, you can take a look into the following examples.

Example for jlink-jpackager-maven-plugin how to build a distroless docker image using the Java jlink tool:

jlink-distroless-maven-example

Minimalistic Example for jlink-jpackager-maven-plugin how to build a installable package using the Java jpackage tool:

jpackager-maven-example