Problem
If a module requires additional modules only for its test cases, the de-facto standard is to define an additional module-info.java file in src/test/java that should be declared open and has a test specific identifier and requires the main module from src/main/java/module-info.java.
Here is an official example from Maven for this use-case: https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html
However, Eclipse does not support that a single project may have more than one module-info.java.
Therefore you get the following error:
Build path contains duplicate entry: 'module-info.java' for project '«project-name»'
Why is this important?
The JPMS is very strict. As soon as I define modules, I need to declare any required module or I can not even import an according class.
So in a library project, I might want to have very minimal required module dependencies (e.g. none at all). However, for implementing my JUnit tests, I might need some logging (java.util.logging or org.slf4j). I do not want to be forced to require that logging in my main module just to be able to use it only in my tests. But otherwise, I can not even add the import to the Logger in my JUnit test class in Eclipse. The logging is just a famous example - this also applies to whatever else you might need additionally for your tests.
With JPMS the entire concept of test scoped dependencies becomes more or less pointless with Eclipse due to this lacking feature.
Impact
Developers of JPMS modules are forced to use a different IDE than Eclipse.
A workaround may be to create an extra projects only for testing. However this has the following drawbacks:
- It does not fit with common standards and confuses developers trying to understand the project
- It causes lots of clutter and maintenance overhead
- In an extra project I can not access the internals of the actual project, I want to test, so I am limited to black-box-testing. However, I commonly want to write JUnits as white-box tests.
Related issues
Sources
|
classpath_duplicateEntryPath = Build path contains duplicate entry: ''{0}'' for project ''{1}'' |
|
Messages.bind(Messages.classpath_duplicateEntryPath, TypeConstants.MODULE_INFO_FILE_NAME_STRING, getElementName()))); |
Problem
If a module requires additional modules only for its test cases, the de-facto standard is to define an additional
module-info.javafile insrc/test/javathat should be declared open and has a test specific identifier and requires the main module fromsrc/main/java/module-info.java.Here is an official example from Maven for this use-case: https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html
However, Eclipse does not support that a single project may have more than one
module-info.java.Therefore you get the following error:
Why is this important?
The JPMS is very strict. As soon as I define modules, I need to declare any required module or I can not even import an according class.
So in a library project, I might want to have very minimal required module dependencies (e.g. none at all). However, for implementing my JUnit tests, I might need some logging (
java.util.loggingororg.slf4j). I do not want to be forced to require that logging in my main module just to be able to use it only in my tests. But otherwise, I can not even add the import to the Logger in my JUnit test class in Eclipse. The logging is just a famous example - this also applies to whatever else you might need additionally for your tests.With JPMS the entire concept of test scoped dependencies becomes more or less pointless with Eclipse due to this lacking feature.
Impact
Developers of JPMS modules are forced to use a different IDE than Eclipse.
A workaround may be to create an extra projects only for testing. However this has the following drawbacks:
Related issues
Sources
eclipse.jdt.core/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties
Line 155 in aea7697
eclipse.jdt.core/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java
Line 3996 in aea7697