An open API service indexing awesome lists of open source software.

https://github.com/ghackenberg/jigsaw-maven-plugin

Maven Plugin for linking and packaging Java applications that include unnamed module dependencies (using jdeps, jlink, and jpackage).
https://github.com/ghackenberg/jigsaw-maven-plugin

Last synced: 9 months ago
JSON representation

Maven Plugin for linking and packaging Java applications that include unnamed module dependencies (using jdeps, jlink, and jpackage).

Awesome Lists containing this project

README

          

# jigsaw-maven-plugin

Linking and packaging Java applications with old-style **unnamed modules** is cumbersome.
The **jigsaw-maven-plugin** tries to simplify this task with three build goals: **patch**, **link**, and **package** (see below).

## Documents

Read the folowing documents to learn more about the project:

* [License](./LICENSE.md)
* [Changelog](./CHANGELOG.md)
* [Contributing](./CONTRIBUTING.md)

Also, do not hesitate to contact the project owner 😉 (ghackenberg@gmail.com).

## Preparations

The **jigsaw-maven-plugin** requires two preparational steps:

1. Output archive
2. Copy dependencies

In the following, each step is described in more detail.

### Step 1: Output archive

Output archive to **modules** folder:

```xml

maven-jar-plugin
3.3.0

${project.build.directory}/modules

```

### Step 2: Copy dependencies

Copy dependencies to **modules** folder:

```xml

maven-dependency-plugin
3.4.0


package


copy-dependencies



${project.build.directory}/modules



```

## Goals

The **jigsaw-maven-plugin** provides three build goals:

* `patch`
* `link`
* `package`

In the following, each goal is described in more detail.

### Goal `patch` (using [jdeps](https://docs.oracle.com/en/java/javase/16/docs/specs/man/jdeps.html) and [javac](https://docs.oracle.com/en/java/javase/16/docs/specs/man/javac.html))

Convert **unnamed modules** (i.e. Java archives missing a **module-info.class** file) to named modules. This step is necessary for **jlink** and **jpackage** to work properly (see following sections). Unfortunatelly, both tools cannot process unnamed modules, which are common in many Java projects until today.

#### Configuration details

The **patch mojo** can be configured as follows:

```xml

io.github.ghackenberg
jigsaw-maven-plugin
1.1.3


jigsaw-patch
package


patch



${project.build.directory}/modules

${maven.compiler.target}

true



```

#### Implementation details

The **patch mojo** searched for unnamed modules (i.e. Java archives missing a **module-info.class** file) in the modules path. For each unnamed module the mojo generates a **module-info.java** file using the **jdeps** tool. Then, the mojo compiles the module descriptors and adds the to the original Java archives. Consequently, unnamed modules are turned into named modules.

### Goal `link` (using [jlink](https://docs.oracle.com/en/java/javase/16/docs/specs/man/jlink.html))

Link **named modules** to executable images. Executable images only include the necessary Java modules. Consequently, smaller executable bundles can be achieved. The executable images can be packaged later using **jpackage** (see next section).

#### Configuration details

The **link mojo** can be configured as follows:

```xml

io.github.ghackenberg
jigsaw-maven-plugin
1.1.3


jigsaw-link
package


link



${project.build.directory}/modules

${project.artifactId}

true

${project.build.directory}/image



```

#### Implementation details

The **link mojo** uses the **jlink** tool internally. The mojo simply wraps the command line call **jlink**.

### Goal `package` (using [jpackage](https://docs.oracle.com/en/java/javase/16/docs/specs/man/jpackage.html))

Package **executable image** to OS-specific installers. OS-specific installers can be used to install the Java application on any target machine running a compatible OS installation. Note that the installers also update previously installed versions of the same Java application. The installers can be built from the executable images generated with **jlink** (see previous section).

#### Configuration details

The **package mojo** can be configured as follows:

```xml

io.github.ghackenberg
jigsaw-maven-plugin
1.1.3


jigsaw-package
package


package



${project.build.directory}/image

${project.build.directory}/modules

${project.artifactId}

path.to.Main

true

-Xmx64m

${project.name}

${project.version}

${project.description}

${project.organization.name}

${project.organization.name}

path/to/license.rtf

path/to/icon.ico

path/to/associations.properties

...

true

true

true

true

${project.organization.name}

${project.build.directory}



```

#### Implementation details

The **package mojo** uses the **jpackage** tool internally. The mojo simply wraps the command line call **jpackage**.