Does maven have a plugin for the new Java 9 jlink
I have searched online but have not been able to find anything official from the maven team.

- 60,316
- 68
- 200
- 288
-
4http://blog.soebes.de/blog/2017/06/06/howto-create-a-java-run-time-image-with-maven/ – khmarbaise Jun 06 '17 at 18:32
4 Answers
Yes. There has been some progress made to create one on Github/maven-plugins for the same.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jlink-plugin</artifactId>
<version>3.0.0-SNAPSHOT</version>
</plugin>
The plugin in its code reads to be adaptive to JEP-282 and JEP-220 from the proposals.
And though this might look like a link too many answer. There is a working example from @khmarbaise on Github as well for this, which requires a toolchain with -
<configuration>
<jdkHome>/Library/Java/JavaVirtualMachines/jdk1.9.0_ea+170.jdk/Contents/Home</jdkHome>
</configuration>
Plus a side note from the author quoting -
Currently not more than a Proof of Concept. Everything here is speculative!
Edit1:- As shared in the comments, additional details could be found @ How to create a Java runtime with Maven.
Edit2:- Dated 10 November, 2018 one can upgrade to using maven-jlink-plugin:3.0.0-alpha-1
and still provide some valuable feedback.

- 27,789
- 26
- 218
- 353
-
Also expecting the author of the shared example shall pitch in soon to correct anything misplaced in the answer. :) – Naman Jun 05 '17 at 06:07
-
2Here I am ;-) ..Can you tell me what the configuration snippet is intended for ? – khmarbaise Jun 05 '17 at 13:14
-
1thats from the prerequisites, just to make sure the toolchain.xml configuration is appropriate in the /.m2 folder of the machine. – Naman Jun 05 '17 at 17:18
-
1Some more informations about it: http://blog.soebes.de/blog/2017/06/06/howto-create-a-java-run-time-image-with-maven/ – khmarbaise Jun 06 '17 at 18:32
I'm working on ModiTect, general tooling around Java 9 modules. One of the goals of the ModiTect Maven plug-in lets you create module runtime images via jlink:
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<id>create-runtime-image</id>
<phase>package</phase>
<goals>
<goal>create-runtime-image</goal>
</goals>
<configuration>
<modulePath>
<path>${project.build.directory}/modules</path>
</modulePath>
<modules>
<module>com.example.module1</module>
<module>com.example.module2</module>
</modules>
<launcher>
<name>helloWorld</name>
<module>com.example.module1</module>
</launcher>
<outputDirectory>
${project.build.directory}/jlink-image
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
The plug-in is under active development right now and must be built from source for the time being (will deploy a first version to Maven Central soon).

- 18,095
- 1
- 53
- 73
-
-
Just curious to know, why should one use this over maven's own plugin? :) – Naman Oct 06 '17 at 01:24
-
The idea behind ModiTect is more that of an entire workflow where you first add module descriptors to the JAR you build and/or its dependencies (assuming they don't have module descriptors yet) and then take all this ad-hoc modularized JARs to build a modular runtime image. – Gunnar Oct 14 '17 at 08:33
there is mvn-jlink plugin which allows to call jdeps and jlink (and any tool provided by jdk), also it can download and unpack needed openjdk version from ADOPT and LIBERICA, such way allows build cross-platform images
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-jlink-wrapper</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>call-jlink</id>
<goals>
<goal>jlink</goal>
</goals>
<configuration>
<jdepsReportPath>${project.build.directory}${file.separator}jdeps.out</jdepsReportPath>
<output>${project.build.directory}${file.separator}preparedJDK</output>
<addModules>
<module>java.compiler</module>
</addModules>
<options>
<option>--compress=2</option>
<option>--no-header-files</option>
<option>--no-man-pages</option>
</options>
</configuration>
</execution>
</executions>
</plugin>

- 833
- 7
- 12
Maybe check out https://github.com/ghackenberg/jigsaw-maven-plugin. The plugin also supports
jdeps --generate-module-info
+javac
+jar
for patching unnamed modules,jlink
for creating runtime images, andjpackage
for creating application installers (only available since JDK 14 though).
You find the plugin documentation on the Github README page.
<plugin>
<groupId>io.github.ghackenberg</groupId>
<artifactId>jigsaw-maven-plugin</artifactId>
<version>1.1.3</version>
</plugin>

- 759
- 5
- 4