Maven standardized support for multi-releases jars

I mean how and where to configure multiple versions in maven? I know I can run an ant task, but can I do it with say maven-compiler plugin or another standardized way?

I believe the maven-compiler-plugin is not the appropriate place to take care of the release or even if we say ant tasks. Its supposed to be compiling the sources of a project seeking the need of which it has though introduced a flag

-release N

whose usage seems similar to that of the -source N and -target N.

It shall compile for a specific VM version(N) and shall support targets: 6, 7, 8, 9. It is similar to the new flag introduced in javac as

--release <release>

The java way of creating a multi-release jar, placing some files in the META-INF/versions/9 directory after this shall be of the format :

jar --create --file mr.jar -C foo classes --release 9 -C foo9 classes

In terms of MR-JAR maven implementation, one of the alternates currently could be as linked by @simas or listed below as proposals(couldn't get to find their released implementations) in one of the analysis.

Note: Shouldn't one rather be interested in moving to JMODs instead of considering MR-JAR for versions 9 and later?

And where and how should I place the different versions of java classes?

In the document Java 9 and its Impact on Maven Projects, the proposals to solve for the MR-JAR has been to either keep a 1 to 1 translation to the structure as mentioned in the JEP-238

project root
 src/main/java
 - A.java
 - B.java
 - C.java
 - D.java
 src/main/java9
 - A.java
 - B.java
 src/main/java10
 - A.java

which though can work with different executions in maven but could possibly be inconvenient to be exposed to IDEs.

Another alternate with a sample hboutemy/maven-jep238 has been listed with the same to make use of following structure:-

multimodule root
 multirelease-base/src/main/java
 - A.java
 - B.java
 - C.java
 - D.java
 multirelease-nine/src/main/java
 - A.java
 - B.java
 multirelease-ten/src/main/java
 - A.java
 multirelease/src/assembly/mvjar.xml

October 4, 2017

I couldn't find an official documentation or implementation where these proposals are consumed by an open source/organisation, hence inferring its not very plainly possible using Maven currently.

Tags:

Maven

Java 9