Reputation: 4336
I'm trying to write a library that can be run on the module path without trouble, but I'm using the org.testcontainers
package for tests, and they have a number of dependencies that doesn't work on the module path.
These are the errors I get when trying to run surefire with my module-info.java
present:
[WARNING] Can't extract module name from visible-assertions-2.1.1.jar: TtyCheck.class found in top-level directory (unnamed package not allowed in module) [WARNING] Can't extract module name from native-lib-loader-2.0.2.jar: native.lib.loader: Invalid module name: 'native' is not a Java identifier [WARNING] Can't extract module name from junixsocket-native-common-2.0.4.jar: junixsocket.native.common: Invalid module name: 'native' is not a Java identifier
These lead to further problems with class not found.
Note that this is a run time problem, the code compiles without problem and the produced jar works.
As far as I have understood the surefire documentation, it tries to run tests on the module path if the module-info.java
file is present.
Is there any way to disable this behavior and fore maven surefire to run the tests on the class path instead of the module path?
Upvotes: 4
Views: 1614
Reputation: 90081
As of Surefire 3.0.0-M2, the correct solution is to set:
<configuration>
<useModulePath>false</useModulePath>
</configuration>
See https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#useModulePath for more information.
Upvotes: 2
Reputation: 4336
I resolved this by adding:
<configuration>
<forkCount>0</forkCount>
</configuration>
To the maven-surefire-plugin plugin section, that gave me the warning [WARNING] useSystemClassloader setting has no effect when not forking
.
Upvotes: 3