tentackle-jlink:jpackage

Full name:

org.tentackle:tentackle-jlink-maven-plugin:21.16.1.0:jpackage

Description:

Creates a java application installer with the jpackage tool.

The mojo works in 4 phases:

  1. Invokes the jlink tool as described in JLinkMojo. This will generate a directory holding the runtime image. However, no run or update scripts and no zip file will be created.
  2. Invokes the jpackage tool to generate the application image from the previously created runtime image. Application- and platform specific options can be configured via the packageImageTemplate.
  3. If the runtime image contains extra classpath- or modulepath-elements, the generated config files will be patched. This is especially necessary to provide the correct classpath order according to the maven/module dependency tree, which usually differs from the one determined by jpackage, because jpackage has no idea about the maven project structure and does its own guess according to the packages referenced from within the jars. This may become an issue if the classpath order is critical, such as configurations overridden in META-INF.
  4. Finally, the installer will be generated from the application image. The packageInstallerTemplate is used to provide additional options to the jpackage tool.
The minimum plugin configuration is very simple:
  ...
  <packaging>jpackage</packaging>
  ...
      <plugin>
        <groupId>org.tentackle</groupId>
        <artifactId>tentackle-jlink-maven-plugin</artifactId>
        <version>${tentackle.version}</version>
        <extensions>true</extensions>
        <configuration>
          <mainModule>com.example</mainModule>
          <mainClass>com.example.MyApp</mainClass>
        </configuration>
      </plugin>
The freemarker templates are copied to the project's template folder, if missing. They become part of the project and can be changed easily according to project specific needs (for example by adding runtime arguments). To install and edit the templates before running jpackage (or jlink, see JLinkMojo), use InitMojo first. In addition to the template variables defined by the JLinkMojo, the variable runtimeDir is provided pointing to the runtime image directory (which is platform specific).

If the application is built with Tentackle's update feature, please keep in mind that applications deployed by an installer are maintained by a platform specific package manager. If the installation is system-wide, the installation files cannot be changed by a regular user. Some platforms, however, also provide per-user installations that can be updated. For Windows, the jpackage tool provides the option --win-per-user-install. MacOS allows the user to decide whether to install system-wide or for the current user only. See isWithUpdater() for more details.

If both jlink zip-files and jpackage installers are required, change the packaging type to jar and add executions, like this:

        <executions>
          <execution>
            <id>both</id>
            <goals>
              <goal>jlink</goal>
              <goal>jpackage</goal>
            </goals>
          </execution>
        </executions>
The jpackage goal will then re-use the previously created jlink image.

The contents of the application image and attachment of the artifacts for installation and deployment can be customized by an application-specific implementation. To do so, provide a plugin dependency that contains a class annotated with @Service(ArtifactCreator).

Important: the jpackage tool is available since Java 14.

Notice that you can create an image for a different java version than the one used by the maven build process via org.tentackle.maven.AbstractTentackleMojo.getToolchain(). Furthermore, you can select the jpackage tool explicitly from another JDK via jpackageToolchain or jpackageTool.

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.

Required Parameters

Name Type Since Description
<imageDirectory> File - The directory created by jlink holding the image.
Default: ${project.build.directory}/jlink
<mainClass> String - The name of the main class.
<variablesPrecedence> String - Defines the precedence of properties and variables.
By default, system properties are overridden by maven properties which are overridden by the extra template variables.

The case-insensitive keywords are:

  • system, sys: for system properties
  • maven, mvn, properties, props, pom: maven properties
  • variables, vars, var, extras, extra, template: extra template variables

Default: system, maven, variables

Optional Parameters

Name Type Since Description
<addModules> List<String> - Extra jre or jdk modules to add to the image.
Useful to add the runtime localization module or extra tools in bin.

Example:

<addModules>
  <addModule>jdk.localedata</addModule>
  <addModule>jdk.jcmd</addModule>
</addModules>
<charset> String - The encoding to read and write files.
Default: ${project.build.sourceEncoding}
<classpathDependencies> List<ClasspathDependency> - Dependencies that should go to the classpath instead of modulepath.
<compress> Integer - Compression of resources.
Corresponds to the jlink option --compress.
<excludeModules> List<String> - Modules to exclude.
Necessary only if a dependency refers to removed api even if not used at all at runtime.
<excludeModules>
  <excludeModule>jdk8internals</excludeModule>
</excludeModules>
<extraClassifier> String - Additional classifier to add to deployed artifacts.
<extraClasspathElements> List<String> - Extra classpath elements.
Pathnames are relative to the image root.
<extraDirectories> List<File> - Extra directories to copy to the image.
<ignoreSigningInformation> boolean - Suppresses a fatal error when signed modular JARs are linked in the runtime image.
Corresponds to the jlink option --ignore-signing-information
Default: false
<jdepsTool> File - Explicit path to the jdeps tool.
Only if toolchains cannot be used.
See also: org.tentackle.maven.AbstractTentackleMojo.getToolchain()
User Property: jdepsTool
<jdkToolchain> Map<String,String> - Toolchain for invocation of external tools.
Explicitly specifies the "jdk" toolchain for this plugin only. Overrides the toolchain selected by the maven-toolchain-plugin, if any.

Example:

  <jdkToolchain>
    <version>14</version>
  </jdkToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jdkToolchain></jdkToolchain>
<jlinkTool> File - Explicit path to the jlink tool.
Only if toolchains cannot be used.
See also: org.tentackle.maven.AbstractTentackleMojo.getToolchain()
User Property: jlinkTool
<jpackageTool> File - Explicit path to the jpackage tool.
Only if toolchains cannot be used.
See also: jpackageToolchain
User Property: jpackageTool
<jpackageToolchain> Map<String,String> - Toolchain for invocation of the jpackage tool only.
Allows to create installers for older java runtime versions not supporting the jpackage tool yet.

Example:

  <jpackageToolchain>
    <version>14</version>
  </jpackageToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jpackageToolchain></jpackageToolchain>
<mainJar> String - The name of the main jar holding the main class.
Only necessary for classpath applications and only if the top-level artifact of the maven dependency tree is not the main jar.
A unique substring is sufficient, e.g. "myapp-server".
<mainModule> String - The name of the module holding the main class.
If missing, the plugin will build an application running on the classpath.
<minLogLevel> String - The minimum logging java.util.logging.Level to redirect java.util logging to the maven logger.
Default: WARNING
<modulePathOnly> List<String> - List of full-blown modules that should be moved to the module path explicitly.
By default, all full-blown modules are passed to the jlink tool. If a module is listed for the module path only, the module it will be moved to the mp folder instead.
This may become necessary, if a 3rd-party full-blown module (illegally!) requires automatic modules, which would cause all artifacts to be moved to the module path by this plugin automatically, since the jlink tool can only handle full-blown modules.

If all modules must be moved to the mp folder, the single values true, all or * can be used as a shortcut.

Examples:

   <modulePathOnly>
       <module>tentackle.log.log4j2v</module>
       <module>org.apache.logging.log4j</module>
   </modulePathOnly>
or
  <modulePathOnly>all</modulePathOnly>
<noHeaderFiles> boolean - Suppress the includes directory.
Corresponds to the jlink option --no-header-files.
Default: false
<noManPages> boolean - Suppress the man directory.
Corresponds to the jlink option --no-man-pages
Default: false
<packageDirectory> File - The directory where to create the installers.
Default: ${project.build.directory}/jpackage
<packageImageTemplate> String - The filename of the jpackage options template to create the application image.
Default: package-image.ftl
<packageInstallerTemplate> String - The filename of the jpackage options template to create the installer.
Default: package-installer.ftl
<packageUpdateTemplate> String - The name of the update script template.
Default: package-update.ftl
<resourcesDirectory> File - The directory holding extra resources, such as logger configurations or database credentials, that will be copied to the conf directory.
Defaults to the maven-resources-plugin's destination directory, usually target/classes.
If no resources must be copied, for example in server-images for production, set this to any non-existent directory, for example "none".
Default: ${project.build.directory}/classes
<saveOpts> File - The optional file holding the jlink options.
Corresponds to the jlink option --save-opts.
<skip> Boolean - Skips processing.
Defaults to true if packaging is "pom".
<stripDebug> boolean - Strip debug information.
Corresponds to the jlink option --strip-debug.
Default: false
<templateDir> File - The directory holding the script templates.
Default: ${project.basedir}/templates
<variables> Map<String,Object> - Extra variables for template or artifact generation.

For example the subproject's basedir:

 <variables>
   <project>${project.basedir}</project>
 </variables>
And then use it in package-image.ftl for file paths, such as:
  --icon ${project}/src/pkg/myapp.ico
<verbosity> String - The verbosity.
One of "default", "info" or "debug". Debug is also turned on (if not set explicitly) by Maven's global debug flag (see command line switch -X).
Default: ${tentackle.verbosity}
<withUpdater> boolean - Enables the auto update feature.

For the jlink gaol an extra update script will be generated via the JLinkMojo.getUpdateTemplate(). The update script will be named bin/update.<extension> where the extension is derived from the platform (cmd on Windows, otherwise sh for unixes).

For the jpackage goal an extra ZIP-file is created holding the jpackage image's files and an update script generated via getPackageUpdateTemplate().

For an implementation of the auto-update feature see the Tentackle modules tentackle-update and tentackle-fx-rdc-update. Whereas tentackle-update can be used by any kind of application, the frontend part tentackle-fx-rdc-update requires a Tentackle FX application.

<zipDirectory> File - The directory where to store the ZIP files.
Default: ${project.build.directory}

Parameter Details

<addModules>

Extra jre or jdk modules to add to the image.
Useful to add the runtime localization module or extra tools in bin.

Example:

<addModules>
  <addModule>jdk.localedata</addModule>
  <addModule>jdk.jcmd</addModule>
</addModules>
  • Type: java.util.List<java.lang.String>
  • Required: No

<charset>

The encoding to read and write files.
  • Type: java.lang.String
  • Required: No
  • Default: ${project.build.sourceEncoding}

<classpathDependencies>

Dependencies that should go to the classpath instead of modulepath.
  • Type: java.util.List<org.tentackle.maven.plugin.jlink.ClasspathDependency>
  • Required: No

<compress>

Compression of resources.
Corresponds to the jlink option --compress.
  • Type: java.lang.Integer
  • Required: No

<excludeModules>

Modules to exclude.
Necessary only if a dependency refers to removed api even if not used at all at runtime.
<excludeModules>
  <excludeModule>jdk8internals</excludeModule>
</excludeModules>
  • Type: java.util.List<java.lang.String>
  • Required: No

<extraClassifier>

Additional classifier to add to deployed artifacts.
  • Type: java.lang.String
  • Required: No

<extraClasspathElements>

Extra classpath elements.
Pathnames are relative to the image root.
  • Type: java.util.List<java.lang.String>
  • Required: No

<extraDirectories>

Extra directories to copy to the image.
  • Type: java.util.List<java.io.File>
  • Required: No

<ignoreSigningInformation>

Suppresses a fatal error when signed modular JARs are linked in the runtime image.
Corresponds to the jlink option --ignore-signing-information
  • Type: boolean
  • Required: No
  • Default: false

<imageDirectory>

The directory created by jlink holding the image.
  • Type: java.io.File
  • Required: Yes
  • Default: ${project.build.directory}/jlink

<jdepsTool>

Explicit path to the jdeps tool.
Only if toolchains cannot be used.
See also: org.tentackle.maven.AbstractTentackleMojo.getToolchain()
  • Type: java.io.File
  • Required: No
  • User Property: jdepsTool

<jdkToolchain>

Toolchain for invocation of external tools.
Explicitly specifies the "jdk" toolchain for this plugin only. Overrides the toolchain selected by the maven-toolchain-plugin, if any.

Example:

  <jdkToolchain>
    <version>14</version>
  </jdkToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jdkToolchain></jdkToolchain>
  • Type: java.util.Map<java.lang.String, java.lang.String>
  • Required: No

<jlinkTool>

Explicit path to the jlink tool.
Only if toolchains cannot be used.
See also: org.tentackle.maven.AbstractTentackleMojo.getToolchain()
  • Type: java.io.File
  • Required: No
  • User Property: jlinkTool

<jpackageTool>

Explicit path to the jpackage tool.
Only if toolchains cannot be used.
See also: jpackageToolchain
  • Type: java.io.File
  • Required: No
  • User Property: jpackageTool

<jpackageToolchain>

Toolchain for invocation of the jpackage tool only.
Allows to create installers for older java runtime versions not supporting the jpackage tool yet.

Example:

  <jpackageToolchain>
    <version>14</version>
  </jpackageToolchain>
To deselect the toolchain configured by the maven-toolchain-plugin:
  <jpackageToolchain></jpackageToolchain>
  • Type: java.util.Map<java.lang.String, java.lang.String>
  • Required: No

<mainClass>

The name of the main class.
  • Type: java.lang.String
  • Required: Yes

<mainJar>

The name of the main jar holding the main class.
Only necessary for classpath applications and only if the top-level artifact of the maven dependency tree is not the main jar.
A unique substring is sufficient, e.g. "myapp-server".
  • Type: java.lang.String
  • Required: No

<mainModule>

The name of the module holding the main class.
If missing, the plugin will build an application running on the classpath.
  • Type: java.lang.String
  • Required: No

<minLogLevel>

The minimum logging java.util.logging.Level to redirect java.util logging to the maven logger.
  • Type: java.lang.String
  • Required: No
  • Default: WARNING

<modulePathOnly>

List of full-blown modules that should be moved to the module path explicitly.
By default, all full-blown modules are passed to the jlink tool. If a module is listed for the module path only, the module it will be moved to the mp folder instead.
This may become necessary, if a 3rd-party full-blown module (illegally!) requires automatic modules, which would cause all artifacts to be moved to the module path by this plugin automatically, since the jlink tool can only handle full-blown modules.

If all modules must be moved to the mp folder, the single values true, all or * can be used as a shortcut.

Examples:

   <modulePathOnly>
       <module>tentackle.log.log4j2v</module>
       <module>org.apache.logging.log4j</module>
   </modulePathOnly>
or
  <modulePathOnly>all</modulePathOnly>
  • Type: java.util.List<java.lang.String>
  • Required: No

<noHeaderFiles>

Suppress the includes directory.
Corresponds to the jlink option --no-header-files.
  • Type: boolean
  • Required: No
  • Default: false

<noManPages>

Suppress the man directory.
Corresponds to the jlink option --no-man-pages
  • Type: boolean
  • Required: No
  • Default: false

<packageDirectory>

The directory where to create the installers.
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}/jpackage

<packageImageTemplate>

The filename of the jpackage options template to create the application image.
  • Type: java.lang.String
  • Required: No
  • Default: package-image.ftl

<packageInstallerTemplate>

The filename of the jpackage options template to create the installer.
  • Type: java.lang.String
  • Required: No
  • Default: package-installer.ftl

<packageUpdateTemplate>

The name of the update script template.
  • Type: java.lang.String
  • Required: No
  • Default: package-update.ftl

<resourcesDirectory>

The directory holding extra resources, such as logger configurations or database credentials, that will be copied to the conf directory.
Defaults to the maven-resources-plugin's destination directory, usually target/classes.
If no resources must be copied, for example in server-images for production, set this to any non-existent directory, for example "none".
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}/classes

<saveOpts>

The optional file holding the jlink options.
Corresponds to the jlink option --save-opts.
  • Type: java.io.File
  • Required: No

<skip>

Skips processing.
Defaults to true if packaging is "pom".
  • Type: java.lang.Boolean
  • Required: No

<stripDebug>

Strip debug information.
Corresponds to the jlink option --strip-debug.
  • Type: boolean
  • Required: No
  • Default: false

<templateDir>

The directory holding the script templates.
  • Type: java.io.File
  • Required: No
  • Default: ${project.basedir}/templates

<variables>

Extra variables for template or artifact generation.

For example the subproject's basedir:

 <variables>
   <project>${project.basedir}</project>
 </variables>
And then use it in package-image.ftl for file paths, such as:
  --icon ${project}/src/pkg/myapp.ico
  • Type: java.util.Map<java.lang.String, java.lang.Object>
  • Required: No

<variablesPrecedence>

Defines the precedence of properties and variables.
By default, system properties are overridden by maven properties which are overridden by the extra template variables.

The case-insensitive keywords are:

  • system, sys: for system properties
  • maven, mvn, properties, props, pom: maven properties
  • variables, vars, var, extras, extra, template: extra template variables
  • Type: java.lang.String
  • Required: Yes
  • Default: system, maven, variables

<verbosity>

The verbosity.
One of "default", "info" or "debug". Debug is also turned on (if not set explicitly) by Maven's global debug flag (see command line switch -X).
  • Type: java.lang.String
  • Required: No
  • Default: ${tentackle.verbosity}

<withUpdater>

Enables the auto update feature.

For the jlink gaol an extra update script will be generated via the JLinkMojo.getUpdateTemplate(). The update script will be named bin/update.<extension> where the extension is derived from the platform (cmd on Windows, otherwise sh for unixes).

For the jpackage goal an extra ZIP-file is created holding the jpackage image's files and an update script generated via getPackageUpdateTemplate().

For an implementation of the auto-update feature see the Tentackle modules tentackle-update and tentackle-fx-rdc-update. Whereas tentackle-update can be used by any kind of application, the frontend part tentackle-fx-rdc-update requires a Tentackle FX application.

  • Type: boolean
  • Required: No

<zipDirectory>

The directory where to store the ZIP files.
  • Type: java.io.File
  • Required: No
  • Default: ${project.build.directory}