I have a project, with Maven and Java 11, which use an external library written in Java 8. It works fine as long as the library is imported as a Jar file. I'm using IntelliJ, but I'm looking for answers that are valid for Eclipse as well.
I have also cloned the external repository from GitHub, and want to use it in source form in my project. One goal is to make improvements to the external library, and be able to send pull requests on it to GitHub. But first I want calls from my project to the library to work without changing anything in the library source code.
However, the class in my project that imports classes from the external library cannot do that.
In pom.xml, I've tried with
<modules>
<module>../path/to/external-libary</module>
</modules>
and it seems to have some effect, but still the imports don't work.
When the library is used as a Jar, this dependency works:
<dependency>
<groupId>com.github.goxr3plus</groupId>
<artifactId>java-stream-player</artifactId>
<version>10.0.0</version>
</dependency>
I suspect that I must do something in either module-info.java or in pom.xml, but I can't figure out what.
If the external library should be seen as an automatic module (being referenced via 'requires' in your module-info, rather than being pulled in on the classpath), then the dependency must point to a jar file, because automatic modules are defined only for jar files.
Eclipse slightly bends the limit by recognizing also projects on the module path as automatic modules, which still requires additional steps when launching, because the Java runtime will not accept a folder of class files as an automatic module.