Eclipse Oxygen: how to determine module dependencies
I am trying to get familiar with Eclipse support for Java 9 modules. I am using Eclipse Oxygen with the Java 9 support package from the market and the latest JDK 9 u180.
The problem has to do with module dependencies and how to let Eclipse know about them.
I understand that in Eclipse a JPMS module corresponds to an Eclipse project. I created three projects aka modules and added the necessary modules-info files:
module com.effjava.app {
requires com.effjava.support;
}
module com.effjava.support {
exports com.effjava.support.hlp;
exports com.effjava.support.test;
exports com.effjava.support.user;
requires transitive com.effjava.util;
}
module com.effjava.util {
exports com.effjava.util.cbk;
exports com.effjava.util.reg;
}
It's a simple chain of dependencies from top to bottom. The module descriptors are correct; I have already managed to set up the same modules in IntelliJ.
My problem is how to tell Eclipse that the top modules depend on the bottom ones, eg. that the middle module com.effjava.support
depends on the lower module com.effjava.util
?
I have set a dependency in a module file (via requires transitive
) and Eclipse accepts this directive without complaint. However, I see an error when compiling the middle module com.effjava.support
. The error message says that the public type from the package is com.effjava.util.cbk
not visible even though it is exported by the module com.effjava.util
and required module com.effjava.support
.
screenshot showing project structure and compiler error message
To indicate the dependency, I exported the content of the bottom module com.effjava.util
to a jar file including module-info.class. Hence it is a modular jar file.
Then I imported the modular jar file into the module com.effjava.support
and added the imported modular jar file to the build path. To no avail.
I tried this without importing, just adding the modular jar as an external library. It didn't work either.
This begs the question: How do I correctly specify module dependencies in Eclipse?
source to share
No one has answered this question yet
Check out similar questions: