jlink:jlink

Full name:

org.apache.maven.plugins:maven-jlink-plugin:3.2.0:jlink

Description:

The JLink goal is intended to create a Java Run Time Image file based on https://openjdk.java.net/jeps/282, https://openjdk.java.net/jeps/220.

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • The goal is not marked as thread-safe and thus does not support parallel builds.
  • Binds by default to the lifecycle phase: package.

Optional Parameters

Name Type Since Description
<addModules> List<String> -

Usually this is not necessary, cause this is handled automatically by the given dependencies.

By using the --add-modules you can define the root modules to be resolved. The configuration in pom.xml file can look like this:

<addModules>
  <addModule>mod1</addModule>
  <addModule>first</addModule>
  .
  .
</addModules>
The command line equivalent for jlink is: --add-modules <mod>[,<mod>...].
<addOptions> List<String> - These JVM arguments will be appended to the lib/modules file.
This parameter requires at least JDK 14.

The command line equivalent is: jlink --add-options="...".

Example:

  <addOptions>
    <addOption>-Xmx256m</addOption>
    <addOption>--enable-preview</addOption>
    <addOption>-Dvar=value</addOption>
  </addOptions>

Above example will result in jlink --add-options="-Xmx256m" --enable-preview -Dvar=value".

<bindServices> boolean - Add the option --bind-services or not.
Default: false
<classifier> String - Classifier to add to the artifact generated. If given, the artifact will be attached as a supplemental artifact. If not given this will create the main artifact which is the default behavior. If you try to do that a second time without using a classifier the build will fail.
<compress> String - Here you can define the compression of the resources being used. The command line equivalent is: -c, --compress=<level>.

The valid values for the level depend on the JDK:

For JDK 9+:

  • 0: No compression. Equivalent to zip-0.
  • 1: Constant String Sharing
  • 2: Equivalent to zip-6.

For JDK 21+, those values are deprecated and to be removed in a future version. The supported values are:
zip-[0-9], where zip-0 provides no compression, and zip-9 provides the best compression.
Default is zip-6.

<disablePlugin> String - You can disable a plugin by using this option. --disable-plugin pluginName.
<endian> String - The byte order of the generated Java Run Time image. --endian <little|big>. If the endian is not given the default is: native.
<ignoreSigningInformation> boolean - --ignore-signing-information
Default: false
<includeLocales> List<String> - Includes the list of locales where langtag is a BCP 47 language tag.

This option supports locale matching as defined in RFC 4647. Ensure that you add the module jdk.localedata when using this option.

The command line equivalent is: --include-locales=en,ja,*-IN.

<includeLocales>
  <includeLocale>en</includeLocale>
  <includeLocale>ja</includeLocale>
  <includeLocale>*-IN</includeLocale>
  .
  .
</includeLocales>
<jdkToolchain> Map<String,String> -

Specify the requirements for this jdk toolchain. This overrules the toolchain selected by the maven-toolchain-plugin.

note: requires at least Maven 3.3.1
<launcher> String - Should the plugin generate a launcher script by means of jlink? The command line equivalent is: --launcher <name>=<module>[/<mainclass>]. The valid values for the level are: <name>=<module>[/<mainclass>].
<limitModules> List<String> - Limit the universe of observable modules. The following gives an example of the configuration which can be used in the pom.xml file.
  <limitModules>
    <limitModule>mod1</limitModule>
    <limitModule>xyz</limitModule>
    .
    .
  </limitModules>
This configuration is the equivalent of the command line option: --limit-modules <mod>[,<mod>...]
<modulePaths> List<String> - Include additional paths on the --module-path option. Project dependencies and JDK modules are automatically added.
<noHeaderFiles> boolean - This will suppress to have an includes directory in the resulting Java Run Time Image. The JLink command line equivalent is: --no-header-files
Default: false
<noManPages> boolean - This will suppress to have the man directory in the resulting Java Run Time Image. The JLink command line equivalent is: --no-man-pages
Default: false
<outputTimestamp> String 3.2.0 Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).
Default: ${project.build.outputTimestamp}
<pluginModulePath> String - Define the plugin module path to be used. There can be defined multiple entries separated by either ; or :. The jlink command line equivalent is: --plugin-module-path <modulepath>
<sourceJdkModules> File - Set the JDK location to create a Java custom runtime image.
<stripDebug> boolean - This is intended to strip debug information out. The command line equivalent of jlink is: -G, --strip-debug strip debug information.
Default: false
<suggestProviders> List<String> - Suggest providers that implement the given service types from the module path.
<suggestProviders>
  <suggestProvider>name-a</suggestProvider>
  <suggestProvider>name-b</suggestProvider>
  .
  .
</suggestProviders>
The jlink command linke equivalent: --suggest-providers [<name>,...]
<verbose> boolean - This will turn on verbose mode. The jlink command line equivalent is: --verbose
Default: false

Parameter Details

<addModules>

Usually this is not necessary, cause this is handled automatically by the given dependencies.

By using the --add-modules you can define the root modules to be resolved. The configuration in pom.xml file can look like this:

<addModules>
  <addModule>mod1</addModule>
  <addModule>first</addModule>
  .
  .
</addModules>
The command line equivalent for jlink is: --add-modules <mod>[,<mod>...].
  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<addOptions>

These JVM arguments will be appended to the lib/modules file.
This parameter requires at least JDK 14.

The command line equivalent is: jlink --add-options="...".

Example:

  <addOptions>
    <addOption>-Xmx256m</addOption>
    <addOption>--enable-preview</addOption>
    <addOption>-Dvar=value</addOption>
  </addOptions>

Above example will result in jlink --add-options="-Xmx256m" --enable-preview -Dvar=value".

  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<bindServices>

Add the option --bind-services or not.
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<classifier>

Classifier to add to the artifact generated. If given, the artifact will be attached as a supplemental artifact. If not given this will create the main artifact which is the default behavior. If you try to do that a second time without using a classifier the build will fail.
  • Type: java.lang.String
  • Required: report.plugin.goal.no

<compress>

Here you can define the compression of the resources being used. The command line equivalent is: -c, --compress=<level>.

The valid values for the level depend on the JDK:

For JDK 9+:

  • 0: No compression. Equivalent to zip-0.
  • 1: Constant String Sharing
  • 2: Equivalent to zip-6.

For JDK 21+, those values are deprecated and to be removed in a future version. The supported values are:
zip-[0-9], where zip-0 provides no compression, and zip-9 provides the best compression.
Default is zip-6.

  • Type: java.lang.String
  • Required: report.plugin.goal.no

<disablePlugin>

You can disable a plugin by using this option. --disable-plugin pluginName.
  • Type: java.lang.String
  • Required: report.plugin.goal.no

<endian>

The byte order of the generated Java Run Time image. --endian <little|big>. If the endian is not given the default is: native.
  • Type: java.lang.String
  • Required: report.plugin.goal.no

<ignoreSigningInformation>

--ignore-signing-information
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<includeLocales>

Includes the list of locales where langtag is a BCP 47 language tag.

This option supports locale matching as defined in RFC 4647. Ensure that you add the module jdk.localedata when using this option.

The command line equivalent is: --include-locales=en,ja,*-IN.

<includeLocales>
  <includeLocale>en</includeLocale>
  <includeLocale>ja</includeLocale>
  <includeLocale>*-IN</includeLocale>
  .
  .
</includeLocales>
  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<jdkToolchain>

Specify the requirements for this jdk toolchain. This overrules the toolchain selected by the maven-toolchain-plugin.

note: requires at least Maven 3.3.1
  • Type: java.util.Map<java.lang.String, java.lang.String>
  • Required: report.plugin.goal.no

<launcher>

Should the plugin generate a launcher script by means of jlink? The command line equivalent is: --launcher <name>=<module>[/<mainclass>]. The valid values for the level are: <name>=<module>[/<mainclass>].
  • Type: java.lang.String
  • Required: report.plugin.goal.no

<limitModules>

Limit the universe of observable modules. The following gives an example of the configuration which can be used in the pom.xml file.
  <limitModules>
    <limitModule>mod1</limitModule>
    <limitModule>xyz</limitModule>
    .
    .
  </limitModules>
This configuration is the equivalent of the command line option: --limit-modules <mod>[,<mod>...]
  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<modulePaths>

Include additional paths on the --module-path option. Project dependencies and JDK modules are automatically added.
  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<noHeaderFiles>

This will suppress to have an includes directory in the resulting Java Run Time Image. The JLink command line equivalent is: --no-header-files
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<noManPages>

This will suppress to have the man directory in the resulting Java Run Time Image. The JLink command line equivalent is: --no-man-pages
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<outputTimestamp>

Timestamp for reproducible output archive entries, either formatted as ISO 8601 yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).
  • Type: java.lang.String
  • Since: 3.2.0
  • Required: report.plugin.goal.no
  • Default: ${project.build.outputTimestamp}

<pluginModulePath>

Define the plugin module path to be used. There can be defined multiple entries separated by either ; or :. The jlink command line equivalent is: --plugin-module-path <modulepath>
  • Type: java.lang.String
  • Required: report.plugin.goal.no

<sourceJdkModules>

Set the JDK location to create a Java custom runtime image.
  • Type: java.io.File
  • Required: report.plugin.goal.no

<stripDebug>

This is intended to strip debug information out. The command line equivalent of jlink is: -G, --strip-debug strip debug information.
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false

<suggestProviders>

Suggest providers that implement the given service types from the module path.
<suggestProviders>
  <suggestProvider>name-a</suggestProvider>
  <suggestProvider>name-b</suggestProvider>
  .
  .
</suggestProviders>
The jlink command linke equivalent: --suggest-providers [<name>,...]
  • Type: java.util.List<java.lang.String>
  • Required: report.plugin.goal.no

<verbose>

This will turn on verbose mode. The jlink command line equivalent is: --verbose
  • Type: boolean
  • Required: report.plugin.goal.no
  • Default: false