I am doing a project to get familiar with Java 9 module system. I intend to use module-info.java files to contain my packages and trim down the jre with jlink. The only dependency in my project is Jsoup. jlink does not support automatic modules so I had to download the source of jsoup, include a module-info.java file and re-package the jar. The jsoup project directory has the following structure after modifications:
JSOUP-PROJECT-DIR
|__src
| |__main
| |__java
| |__org
| | |__jsoup
| | |
| | ...
| | ...
| |
| |__module-info.java
|
|__target
|
...
...
The module-info.java
file has following content:
module org.jsoup {
requires java.xml;
exports org.jsoup;
exports org.jsoup.nodes;
exports org.jsoup.select;
}
I did a clean compilation and repackaging to get the jar with module-info.class: mvn clean package
Then I added this jar as a maven dependency in my project (replacing the original jsoup-x.x.x.jar with the modified one in local repository inside .m2). My project, that depends on Jsoup, has the standard maven directory structure with module-info.java sitting inside the java directory. The module-info.java of this project contains this:
module org.mediacat {
requires org.jsoup;
requires jdk.crypto.ec;
exports org.mediacat.torrent_engine;
}
IntelliJ gives an error in the first line of my project's module info file,
Module org.mediacat reads package 'org.jsoup' from both 'org.jsoup' and 'org.jsoup'
I don't understand what it's trying to convey. Despite this inspection, when I do mvn clean compile -Dtest=MyTests test
, everything works smoothly. I don't get any kind of warning or error. On top of that, I am able to create the custom jre with jlink --module-path target --add-modules java.base,org.mediacat,org.jsoup --output jre
(I manually copied the modified jsoup.x.x.x.jar in the target directory of my project). The error highlighted in IntelliJ is super annoying. I'm worried if I am making a mistake. I want to know if I am actually, or it's possibly a bug in IntelliJ (or maybe my project is wrongly configured)?
EDIT: By the way, when the application is ran through a run configuration generated by IntelliJ Idea (by clicking the green run gutter icon where main function is defined), again, the program compiles and runs just fine.