Add a JPMS module descriptor

Issue #492 wontfix
Benjamin Marwell created an issue

I already tried to, but I cam back with a little more knowledge 🙂

Please add a Java 9+ JPMS module descriptor. PR will follow.

Technical details of the upcoming PR

  1. Add a java9+ <profile><id>java9</id></profile>
  2. In this profile, the folder src/main/java9 is added as an additional source folder
  3. The source folder contains a module-info.java.

This will require a JDK9+ for compilation, but the whole rest of the source code will still produce java8 bytecode. I.e. no compatiblity issues.

The only file which will be compiled to Java9+ is the module descriptor. It will transparently be included in the resulting jar archive.

We do this in the maven-jlink-plugin the same way. A lot of plexus maven plugins do this as well.

Jlink example:

Benefit / User stories

Applications requiring snakeyaml will be able to be packed into a jlink or jpackage archive, or even easier with the client-maven-plugin for gluon. At the moment this will not work, as at least jlink and jpackage require all dependencies to be modules.

Comments (10)

  1. Andrey Somov

    Please be aware that SnakeYAML is under Java 7 (not Java 8)

    I am afraid it will create compatibility issues.

    Why not to migrate to Engine ? And implement this there ?

  2. Benjamin Marwell reporter

    Hi Andrey, it does not really matter if it is Java 7 or 8. The only difference will be that there is a new META-INF/java9 directory in the jar file, containing a module-info.java.

    What is “Engine”?

  3. Alexander Maslov

    I see you mention client-maven-plugin plugin. So, I expect you want to cross-platform application (like Android maybe).
    But android version and non-android version would need to have different module-info.java files (e.g. android one does not require java.desktop).

    I think making multirelease jar should not be a problem, since maven-compile-plugin supports it.

    But I am not sure should we really do it in this project.
    I guess it is also possible to use https://github.com/moditect/moditect to inject module-info.class for the dependencies missing it.

  4. Benjamin Marwell reporter

    I am not able to get the tests working 😞 I could upload a draft PR if you wish.

    Btw: I do not think snakeyaml requires java.desktop at all.

  5. Benjamin Marwell reporter

    About snakeyaml-engine: Oh great! I didn’t know about that! I will now convert to snakeyaml-engine.

    You are right that this issue will not make sense here. Thanks for the clarification! 🙂

  6. Log in to comment