how to pass --add-opens JDK module configuration to maven test
Asked Answered
R

1

58

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?

Reamy answered 19/11, 2020 at 21:48 Comment(0)
A
61

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>
Albina answered 19/11, 2020 at 22:3 Comment(1)
Do you know how to add when using Gradle?Perihelion

© 2022 - 2024 — McMap. All rights reserved.