Skip to content
Advertisement

how to pass –add-opens JDK module configuration to maven test

I’m upgrading java version in our production code from java 8 to java 11.

I have to add the below JDK module configuration in the application java start command due to usage of third party libraries like flume, zookeeper etc.

--add-opens java.base/java.lang=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED

After adding this configuration and java application is starting fine.

But when I run the tests using mvn test the tests are failing. I’ve added the below configuration to the maven-surefire-plugin but still it is throwing error.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M5</version>
    <configuration>
        <argLine>--illegal-access=permit</argLine>
        <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
        <argLine>--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED</argLine>
        <argLine>-Dillegal-access=permit</argLine>
    </configuration>
</plugin>

I think I’m not passing the argument correctly in the maven test. Any idea what I’m doing wrong and how to fix this?

Advertisement

Answer

It is a single argLine, like:

<argLine>
    --add-exports org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED
    --add-exports org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED
</argLine>

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement