Maven project with a mix of Java 9 modules and Java 8 automatic modules

Answered

I've two maven projects:

  • Project P8, built for the Java 8 platform
  • Project P9, built for the Java 9 platform, with a dependency on Project P8.

I've tried different approaches:

  1. Specify an automatic module name in the manifest of Project P8, and use that name in the requires clause of Project P9.
  2. Use the default automatic module name of Project P8
  3. Specify a module-info.java file in the META-INF/versions/9 folder of Project P8

Approach 1: a very naive approach where the name of the module is specified in the maven-jar-plugin in Project P8

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>my.module</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
module my.other.module {
requires my.module;
}

Approach 2: same naive approach, but nothing is added to the manifest. The name of the artifact being my-module, the module-info.java file contains:

module my.other.module {
requires my.module;
}

Approach 3: a multi-release jar file is build with a module-info.java file placed in META-INF/versions/9

 

All these approaches could be compiled with success with the java compiler.

But in Intellij, Project P9 fails to compile with an error reporting that my.module could not be found.

What's the recommended way to support a mix of Java 9 and Java 8 maven projects in Intellij?

 

0
3 comments

Looks like a bug, please report at https://youtrack.jetbrains.com/issues/IDEA.

If it builds with a command line Maven, it should also build in IntelliJ IDEA.

0
Avatar
Permanently deleted user

Done, thank you.

0
Avatar
Permanently deleted user
0

Please sign in to leave a comment.