Copilot commented on code in PR #3523:
URL: https://github.com/apache/maven-surefire/pull/3523#discussion_r4572750105


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -2101,21 +2104,35 @@ private StartupConfiguration 
newStartupConfigWithModularPath(
             providerClasspath = 
classpathCache.setCachedClasspath(providerName, providerArtifacts);
         }
 
-        // the Maven 3 guesses about what goes on the module path, see 
ModulePathJpmsArguments
+        final Set<String> testModuleNames;
         final ModulePathJpmsArguments.Layout layout;
         if (isMainDescriptor) {
+            // the Maven 3 guesses about what goes on the module path, see 
ModulePathJpmsArguments
             for (String className : scanResult.getClasses()) {
                 packages.add(substringBeforeLast(className, "."));
             }
 
             layout = ModulePathJpmsArguments.forMainModule(
                     getLocationManager(), testClasspath, javaModuleDescriptor, 
javaHome, packages, getConsoleLogger());
+            testModuleNames = layout.getModuleNames();
         } else {
+            if (JUNIT_PLATFORM_PROVIDER_NAME.equals(providerName)) {
+                ResolvePathsRequest<String> req = 
ResolvePathsRequest.ofStrings(testClasspath.getClassPath())
+                        .setIncludeAllProviders(true)
+                        .setJdkHome(javaHome)
+                        .setIncludeStatic(true)
+                        .setModuleDescriptor(javaModuleDescriptor);
+                testModuleNames = 
ModulePathJpmsArguments.moduleNamesOnModulepath(
+                        getLocationManager().resolvePaths(req));

Review Comment:
   With a separate test descriptor, Commons can be a test dependency without 
being required by `module-info.java`; the resolver can then omit it from its 
module-path subset, although the fork places the entire test path on the module 
path with `ALL-MODULE-PATH`. This removes the existing Commons opens while 
Commons is still a named module, leaving classpath-based provider code without 
the required package access. Collect names from all resolved test-path 
descriptors in this branch, and add a regression case where Commons is present 
but not required by the descriptor.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to