Get maven surefire to run on classpath with module-info.java file present

Viewed 794

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?

2 Answers

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.

Related