JPMS/Jigsaw-compatible Java library targeting older JDKs

89 Views Asked by At

I'm trying to figure out how to use Maven to build a library jar file that is compatible with JDK 7 and 8 but includes a module-info.java file an explicitly declares its public API.

Problem: I need to compile for old target versions but the old JDKs obviously don't know the new JPMS features.

In this talk by Robert Scholte it seems like the best approach is to only compile the module-info file with JDK9. But how do I include it into the .jar then?

Any minimal example pom.xml would be of great help! :-)

Edit: Just to be clear: I don't get any compiler errors. I was just asking about the basic concept of using JPMS for JDK 9 users but keep my library backwards-compatible with JDK 7 and 8.

0

There are 0 best solutions below