When a Java 9 modular system integrates into Maven, how to handle an automatic module

I already practiced integration with the java 9 module with the Maven project. and it seems to work well, but I was worried about backwards compatibility of the maven module compiled before java 9.

For backward compatibility, the Java Platform Module System (JPMS) provides an automatic module concept. In JPMS, a Jar file without module-info.java is considered an automatic module, and another java module can use this jar file using its file name as the name of the module.

In case of integration with the maven project, I think additional support for backward compatibility of JPMS is needed. firstly, the main jar file and the maven jar file are not the same structure. secondly, the maven jar file name is incompatible with the rule, which may be compatible with the JPMS module naming rule. see the example below.

<artifactId>previous-version-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

In the above cases, we already use the module of the previous version-0.0.1-SNAPSHOT and want to use this module in the new java 9 maven project.

module new.module{
  requires previous-version-module-0.0.1-SNAPSHOT
}

but it causes a compilation error or an error loading the IDEA tool.

I am wondering how to use the maven jar file that was compiled before java 9 in java 9 and the maven integration project. I was looking for some additional module definition rule or maven plugin, I can not find any solution.

Thank.

+4
1

, jar --file=<jarfile> --describe-module, . --list-modules, .. java -p <jarfile> --list-modules.

, requires <module>, . maven-compiler -info.java .

+6

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


All Articles