Introduction
jar-module is a plugin for maven to package the jar.
The first option is to clean a jar file from the directory entries and to set the main-class in module-main.class as found in the manifest file.
The main option is to call jlink to generate a java with only the used modules as runtime. All needed jar are copied in one directory to update the automatic modules to be real modules.
After that the call to jlink is possible.
The other option is to generate an installer for windows, macOS, linux or an image. It uses the javapackager and it's required tools. Only available for Java 9 and 10 of Oracle JDK. Not in Open JDK.
Documentation
The generated site documentation of the maven plugin jar-module can be viewed at
https://mt-ag.github.io/jar-module-maven-plugin/
Requirements
Java version 9 or newer.
Maven to build the maven-plugin.
Maven to use the maven-plugin.
For goal javapackager an Oracle JDK 9 or 10 is needed.
Download
The link to the maven repository: https://search.maven.org/search?q=a:jar-module-maven-plugin
Build
Usage
<plugin>
<groupId>com.mt-ag.tools.maven</groupId>
<artifactId>jar-module-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<repack>true</repack>
<openmodule>false</openmodule>
<appName>LinkListe</appName>
<appMenuGroup>MT AG</appMenuGroup>
<appVendor>MT AG</appVendor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>jlink</goal>
<goal>javapackager</goal>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
The goal jar
sets the main-class
if it is a module and the main class is not set but the Main-Class
is set in the manifest. Cleans the jar if repack
is true.
The goal jlink
calls the jlink
in the sub dir modules
and copies all jars
from the dependencies to the modules
folder. The new java runtime
is found in the run
sub folder. It is packed as zip-file
in the artifact name ending with .run.zip
. The classifier is run
in the additional artifact.
The goal javapackager
calls the javapackager to create an installer for the jar. The installer is packed into the zip-file
in the artifact name ending with .install.zip
. The classifier is install
in the additional artifact.