Eclipse maven compiler not supporting compiler-plugin compilerArgs

前端 未结 1 1696
面向向阳花
面向向阳花 2021-01-16 10:37

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

相关标签:
1条回答
  • 2021-01-16 10:59

    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:

    • Put the test code into src/test/java/ instead of into a separate project (accessing internals indicates that it is an unit test rather than an integration test)
    • In the separate (integration) test project do not access interal stuff of required module
    • Do not use JPMS in the separate (integration) test project
    0 讨论(0)
提交回复
热议问题