We have a collection of Java module projects (using JDK11).
There is a separate project for our integration tests. This project needs to be able to access the main a
The --add-exports
compiler argument can be set manually for Maven dependencies in the .classpath
file by replacing
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
with
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="add-exports" value="com.example.application/com.example.application=com.example.integration_tests"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Unfortunately, right-clicking the project and choosing Maven > Update Project... reverses the manual settings.
See: Eclipse bug 543631 - Eclipse - Maven - JPMS (please comment and vote there if you would like to have this feature)
To restore your manual settings after updating the project, you can replace the .classpath
file with its version before updating the project.
Please consider the following alternatives to a separate project for test code that uses JPMS but accesses internal stuff of a module:
src/test/java/
instead of into a separate project (accessing internals indicates that it is an unit test rather than an integration test)