Skip to content

The JLink Maven Plugin lets you create a custom runtime image with the jlink tool introduced in Java 9

License

Notifications You must be signed in to change notification settings

Akman/jlink-maven-plugin

Repository files navigation

JLink Maven Plugin v0.1.11

Build Status Maven Central License

The jlink maven plugin lets you create a custom runtime image with the jlink tool introduced in Java 9.

The main idea is to avoid being tied to project artifacts and allow the user to fully control the process of creating an image. However, it is possible, of course, to customize the process using project artifacts.

The detailed documentation for this plugin is available here.

Goals

This plugin has two goals:

  • jlink:jlink is not bound to any phase within the Maven lifecycle and is therefore is not automatically executed, therefore the required phase must be specified explicitly.

  • jlink:help display help information on the plugin.

To create a custom runtime image manually you need only to execute:

mvn jlink:jlink

It will not fork (spawn a parallel) an alternate build lifecycle and will execute the jlink goal immediately.

To display parameter details execute:

mvn jlink:help -Ddetail=true

Usage

Add the plugin to your pom:

  <project>
    ...
    <build>
      <pluginManagement>
        <plugins>
          ...
          <plugin>
            <groupId>com.github.akman</groupId>
            <artifactId>jlink-maven-plugin</artifactId>
            <version>0.1.11</version>
          </plugin>
          ...
        </plugins>
      </pluginManagement>
    </build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>com.github.akman</groupId>
        <artifactId>jlink-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>jlink</goal>
            </goals>
            <configuration>
              <!-- put your configurations here -->
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </project>

If you want to use snapshot versions of the plugin connect the snapshot repository in your pom.xml.

  <project>
    ...
    <pluginRepositories>
      <pluginRepository>
        <id>ossrh</id>
        <name>OSS Sonatype Snapshots Repository</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <layout>default</layout>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
        <releases>
          <enabled>false</enabled>
        </releases>
      </pluginRepository>
    </pluginRepositories>
    ...
  </project>

And then build your project, jlink starts automatically:

mvn clean verify

Links

The JLink tool official description.

JEP-220 Modular runtime images.

Pull request

Pull request template: .github/pull_request_template.md.

About

The JLink Maven Plugin lets you create a custom runtime image with the jlink tool introduced in Java 9

Topics

Resources

License

Stars

Watchers

Forks

Languages