For detailed information about jpackage
please refer to
Packaging Tool User's Guide.
Plugin searches for jpackage
executable using the following priority list:
maven-toolchains-plugin
configured in the project. Toolchain “jdk” will be queried for
tool = “jpackage”.
java.home
system property.
There are generic parameters as well as OS-specific parameters for OS X and Windows.
Plugin determines OS name using os.name
system property in order to configure OS-specific parameters.
Generic parameters should be placed in the root plugin configuration. OS-specific parameters should be separated with executions or profiles.
See examples:
To enable various configuration approaches mandatory parameters are validated during plugin execution:
The following plugin parameters define directory or file location:
If path is not absolute is will be resolved as relative to ${project.basedir}
.
One exception is installDir
which is passed as is.
<javaOptions> defines options for JVM running the application. Each option should be specified in a separate <option> tag.
Example:
<javaOptions>
<javaOption>--enable-preview</javaOption>
<javaOption>-Dfile.encoding=UTF-8</javaOption>
<javaOption>--add-export</javaOption>
<javaOption>java.base/sun.security.util=ALL-UNNAMED</javaOption>
</javaOptions>
Default command line arguments are passed to the main class when the application is started without providing arguments. Each argument should be specified using <argument> configuration parameter.
Example:
<arguments>
<argument>SomeArgument</argument>
<argument>Argument with spaces</argument>
<argument>Argument with "quotes"</argument>
</arguments>
Additional launchers provide the opportunity to install alternative ways to start an application.
Example:
<launchers>
<launcher>
<name>App1</name>
<file>src/resources/App1.properties</file>
</launcher>
<launcher>
<name>App2</name>
<file>src/resources/App2.properties</file>
</launcher>
</launchers>
If you want your application to be started when a user opens a specific type of file, use <fileAssociations>
configuration.
Example:
<fileAssociations>
<fileAssociation>src/properties/java.properties</fileAssociation>
<fileAssociation>src/properties/cpp.properties</fileAssociation>
</fileAssociations>
Note: apparently this option does not work for modular applications.
Options that are passed to underlying jlink call.
Example:
<jLinkOptions>
<jLinkOption>--strip-native-commands</jLinkOption>
<jLinkOption>--strip-debug</jLinkOption>
</jLinkOptions>
Additional options allow passing jpackage command line options not supported by the plugin. These options are passed as is without any transformation.
Example:
<additionalOptions>
<option>--jlink-options</option>
<option>--bind-services</option>
</additionalOptions>
Before executing jpackage
all runtime dependencies should be copied into a single folder together with main
application jar. This example shows how to do this via maven-dependency-plugin
.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>target/jmods</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>target/jmods</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.panteleyev</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<configuration>
<modulePaths>
<modulePath>target/jmods</modulePath>
</modulePaths>
</configuration>
</plugin>
</plugins>
To print jpackage parameters without executing jpackage set jpackage.dryRun
property to true
.
Example:
mvn clean package jpackage:jpackage@win -Djpackage.dryRun=true