Skip to content

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

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.

        <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>

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?



It is a single argLine, like:

    --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