[ https://issues.apache.org/jira/browse/SUREFIRE-1563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16601262#comment-16601262 ]
Simone Bordet commented on SUREFIRE-1563: ----------------------------------------- Some more food for thoughts. Seems natural for {{src/test/main}} to have its own {{module-info.java}}, rather than a file with a different name but same semantic. This may be even more important when a module produces the {{test-jar}} containing stuff used for testing that is useful for other modules. For example, in Jetty we have a utility class {{HttpTester}} class that simulates a HTTP client that lives in the test sources of module {{org.eclipse.jetty.http}}, and we produce the {{test-jar}}. The tests for module {{org.eclipse.jetty.server}} depends on the {{test-jar}} of {{org.eclipse.jetty.http}}. What I have to do right now is to add: {code} --patch-module org.eclipse.jetty.http=${settings.localRepository}/org/eclipse/jetty/jetty-http/${project.version}/jetty-http-${project.version}-tests.jar {code} in the {{jetty-server}} Maven module, for both the {{maven-compiler-plugin}} configuration and for the {{maven-surefire-plugin}} configuration. (Unfortunately I cannot make it work for the {{maven-compiler-plugin}}, probably because there is a space between {{--patch-module}} and the rest. Strangely enough, if I put a {{=}} instead of the space, just after {{--patch-module}}, it seems to work ?!?). However, Maven would then need to detect the {{test-jar}} and treat it differently: cannot put it in the {{module-path}} as it would export the same packages as its correspondent module, so it would need to patch the module like I manually do in the POM now. > NoClassDefFoundError for JPMS modules with "require static" > ----------------------------------------------------------- > > Key: SUREFIRE-1563 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1563 > Project: Maven Surefire > Issue Type: Bug > Components: Maven Surefire Plugin > Affects Versions: 2.22.0 > Reporter: Simone Bordet > Priority: Major > Attachments: maven-jpms.tgz > > > When a Maven module has a {{module-info.java}} that contains a {{requires > static}}, Surefire throws {{NoClassDefFoundError}} when running the tests for > that Maven module. > If the dependency is declared only as {{required}} (no {{static}}), then the > tests run fine. > Attached a reproducible project. -- This message was sent by Atlassian JIRA (v7.6.3#76005)