Standard Maven Support for Multi-Disc Jars

Java 9 is released with JEP-238 , which basically allows us to send multiple versions of the execution classes. The question is, how is this JEP supported by maven?

  • I mean, how and where to configure multiple versions in maven? I know that I can run the ant task, but can I do this using the maven-compiler plugin or some other standardized way?
  • And where and how should I post different versions of java classes? JEP restricts the compiled class files and tells us where we should put it in the jar, but what about development?
+6
source share
3 answers

I mean, how and where to configure multiple versions in maven? I know I can run the ant task, but can I do this using the maven-compiler plugin or another standardized way?

I believe that maven-compiler-plugin not suitable for maintenance of a release or even if we say ant tasks. He was supposed to compile the sources of a project that needed to have at least a flag.

 -release N 

using which is similar to using -source N and -target N

It should compile for a specific version of VM (N) and support the goals: 6, 7, 8, 9. It looks like a new flag introduced in javac as

 --release <release> 

The java way to create a banner with several releases, placing some files in the META-INF/versions/9 directory after that, will have the format:

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

In terms of the implementation of MR-JAR maven, one of the alternatives can currently be linked as @simas or listed below as sentences (could not find their released implementations) in one of the analyzes.

<sub> Note . Shouldn't you be more interested in JMOD to JMOD instead of considering MR-JAR for versions 9 and later?

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

In the Java 9 document and its impact on Maven projects , the solution proposals for MR-JAR were to either save 1 to 1 translations into the structure, as specified in 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 can work with different executions in maven, but it can be inconvenient to expose itself to the IDE.

Another option with the hboutemy / maven-jep238 sample was specified in the same order to use the 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 could not find the official documentation or implementation where these proposals are consumed by open source / organization, so the conclusion is that it cannot be explicitly available using Maven at the moment.

+3
source

SLF4J seems to work with multiple modules.

0
source

Source: https://habr.com/ru/post/1272323/


All Articles