Because consumer
is now modular in the updated example project, the dependency to lib
must also stay modular and the workaround cannot be applied anymore.
The test class LibraryTest
is not exported in the module-info.java
of lib
. Without a second module-info.java
, which isn’t currently supported by JDT, this class cannot be imported in consumer
.
JDT has a concept for separating main and test sources and maintaining different classpaths for them, but a project dependency like lib
can only be imported as a main or test dependency. So it is not possible to configure lib
as modular for the main classpath and non modular for the test classpath the same time.
Splitting the lib
project into two separate projects - one for the main sources and one for the test sources - could possibly work. As proposed in Support additional module-info.java for tests, if that ends up being de-facto standard · Issue #1465 · eclipse-jdt/eclipse.jdt.core · GitHub Maven (or Gradle) could do this under the hood. But I think, the different representations of projects in Gradle (or filesystem) and Eclipse are hard to understand and lead to a bad user experience.