Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliJ complains about duplicate module-info.java #11

Open
AndreG-P opened this issue Feb 20, 2020 · 8 comments
Open

IntelliJ complains about duplicate module-info.java #11

AndreG-P opened this issue Feb 20, 2020 · 8 comments

Comments

@AndreG-P
Copy link

I've tried the newest version of IntelliJ EAP (2020.1) and still, IntelliJ complains about the two module-info.java via:

'module-info.java' already exists in the module

Maven compiles just fine though. And I was not able to find any other problems besides these red underlines that indicate errors in IntelliJ.
Any ideas about that?

@sormuras
Copy link
Contributor

Which IDEA module contains the error?

@AndreG-P
Copy link
Author

Every (maven) module with two module-info.java:
modular-whitebox-patch-compile
modular-blackbox-stereo

@sormuras
Copy link
Contributor

sormuras commented Feb 21, 2020

I see.

That's why I invented and promoted the module-info.test work-around as described in https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world#white-box-modular-testing-with-extra-java-command-line-options

Caveat: IDEA, Maven Surefire and most other tools don't support module-info.test, though. Trying together with Robert to convince the Jigsaw-Crew to improve the situation: http://mail.openjdk.java.net/pipermail/jigsaw-dev/2020-February/thread.html#14357

@AndreG-P
Copy link
Author

It's actually a shame that there is no proper solution yet. Java 9 is over 2 years old already.

I think I have also a small hack for this. If the test-packages also exist in the main path, one can opens the packages just to the test engine. For example, in modular-whitebox-path-compile, we can change the module-info.java in the main/java to:

module foo {
  exports foo;
  opens foo to org.junit.platform.commons;

  requires java.logging;
  requires org.junit.jupiter.api;
}

This also works with surefire and the newest versions of junit.
Even though this is definetly not a good way to do it.

@sormuras
Copy link
Contributor

[...]
Even though this is definetly not a good way to do it.

Exactly. I'd go even further and state: that's an absolute no-go!

Don't mess with the main descriptor just for the purpose of testing. The main descriptor is meant to be re-used, potentially published to Maven Central and shall only contain the minimal required API to work properly.

@AndreG-P
Copy link
Author

So for now (even two years since java 9), it looks like one should not mess up with Intellij, maven and jigsaw. It seems the best to avoid javas module system until there is a common solution that is supported by intellij, maven surefire, and jigsaw.

Am I right?

@sormuras
Copy link
Contributor

It depends and only time will tell.

Jigsaw + Foundation Tools (javac, jar, javadoc, ...) are fine. Of course, there are still bugs within those tools regarding the module system support.

Most "vintage" build tools took and take Java packages as their building blocks -- due to the fact there weren't Java modules around when those tools were created. Some tools (and underlying project models) may adopt, some won't.

@sormuras
Copy link
Contributor

sormuras commented Sep 7, 2021

Soon, it'll work with IntelliJ's IDEA: https://youtrack.jetbrains.com/issue/IDEA-253066#focus=Comments-27-5173827.0-0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants