Is there any way to use jlink in IntelliJ IDEA to create a custom modular run-time image?
Asked Answered
G

1

14

I'm following the Project Jigsaw: Module System Quick-Start Guide in IntelliJ IDEA 2018.2.5. I did everything right in the IDE until The linker section. Is there any way to use jlink in IntelliJ IDEA?

jlink (see JEP 282) is the linker tool and can be used to link a set of modules, along with their transitive dependences, to create a custom modular run-time image (see JEP 220).
- Project Jigsaw: Module System Quick-Start Guide

I found this Ability to produce JLink artefacts issue in JetBrains Bug & Issue Tracker, but it has been open for more than 2 years and it doesn't even have a description.


As a workaround, I have seen this Is there a maven jigsaw jlink plugin? interesting question and the most promising alternative seems to be the Apache Maven JLink Plugin, but it has also been there for more than 2 years and it hasn't been released yet.

Guardrail answered 9/11, 2018 at 17:18 Comment(3)
Since you've linked to one of the questions I'd answered(updated there as well). Did you give maven-jlink-plugin:3.0.0-alpha-1 a try? Feedback is a crucial aspect before moving that to releases I believe. The blog linked in the answer there should help you with the process.Sufflate
Thanks @nullpointer. I didn't really try the plugin (yet), I'm just starting to try the new Java features since version 9. The question is how to use jlink in IntelliJ IDEA, I just thought of Maven as an alternative within the IDE and I was disappointed not to find a stable solution. Even according to documentation, the current version of this plugin requires JDK 9, when the latest version is 11.Guardrail
The exact question of using jlink via IntelliJ seems to have been answered by the links you've shared in the question to me (we can wait for a contributor of IntelliJ to actually confirm.) Regarding the plugin you can track the updates in the actual source repository and contribute further.Sufflate
L
1

You could use Ant as a build tool and specify your own jlink target, like this:

<target name="link">
    <echo message="Creating jlink image in directory = dist\bin\java" />
    <exec executable="jlink">
        <arg line='--module-path bin;"C:\Program Files\Java\jdk-11.0.1-Linux\jmods";"C:\Users\VTorroni\_libs\hsqldb-2.4.1\modules";"C:\Users\VTorroni\_libs\tinylog-1.3.5\module";"C:\Users\VTorroni\_libs\javax.servlet-api-4.0.1\module\javax.servlet.api-4.0.1.jar" --add-modules pnode --output dist\bin\java --strip-debug --no-header-files --no-man-pages --compress=2' />
    </exec>
</target>
Leap answered 21/1, 2020 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.