Using Java 9 modules with explicit Automatic Module Name in IntelliJ Idea

Viewed 22

I have a Maven multi-module project, containing the following files, amongst others:

  • pom.xml
  • legacy/pom.xml
  • v2/pom.xml
  • v2/src/main/java/module-info.java

legacy/pom.xml includes the following statement:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.3.0</version>
    <configuration>
        <archive>
            <manifestEntries>
                <Automatic-Module-Name>mycompany.legacy.api</Automatic-Module-Name>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

And v2's module-info.java is as follows:

module v2 {
    requires mycompany.legacy.api;
}

Running a Maven Build from the command line is fine, and the project runs. However IntelliJ complains because it can't find the module mycompany.legacy.api, meaning that the packages exposed by the legacy project aren't considered as available when editing code in the v2 project.

If I change module-info.java to requires legacy.api; then IntelliJ is happy, but that's not the name I want.

Is there a way to tell IntelliJ that the Java 9 module is named mycompany.legacy.api?

(I'm using 2022.2.2 (Community Edition))

0 Answers
Related