desruisseaux commented on code in PR #3395:
URL: https://github.com/apache/maven-surefire/pull/3395#discussion_r3624275856
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java:
##########
@@ -204,29 +205,40 @@ File createArgsFile(
.append('"')
.append(NL);
- // Check for module-info-patch.args generated by
maven-compiler-plugin 4.x
- Path patchArgs = findModuleInfoPatchArgs(patchFile);
- if (patchArgs != null) {
- // Merge the file's directives, except
--add-reads/--add-modules
- // which surefire manages itself (see
appendModuleInfoPatchArgs)
- appendModuleInfoPatchArgs(args, patchArgs, moduleName);
+ // module-info-patch.args generated by maven-compiler-plugin
4.x
+ Path patchArgsPath = findModuleInfoPatchArgs(patchFile);
+ if (patchArgsPath != null) {
+ patchArgs =
ModuleInfoPatchArgsFile.parse(patchArgsPath.toFile());
}
-
- // Always auto-generate --add-opens for test packages (JUnit
needs reflection access).
- // module-info-patch.maven cannot use ALL-UNNAMED in
add-opens, so surefire handles this.
- for (String pkg : packages) {
- args.append("--add-opens")
- .append(NL)
- .append(moduleName)
- .append('/')
- .append(pkg)
- .append('=')
- .append("ALL-UNNAMED")
- .append(NL);
+ if (patchArgs != null) {
+ // #3090: the developer-controlled handoff file is the
+ // single source of truth — pass it through verbatim. Its
--add-modules
+ // dependencies are named modules on the module path
(moved there by
+ // AbstractSurefireMojo), so the directives resolve in the
boot layer.
+ for (String line : patchArgs.getLines()) {
+ args.append(line).append(NL);
+ }
+ // the patched module itself must still be a resolution
root
+
args.append("--add-modules").append(NL).append(moduleName).append(NL);
Review Comment:
Maybe replace the first `NL` by a space for consistency with the options
added above. The goal is to make the file not only machine readable, but also
human readable. I think that it is a little bit easier to understand when we
have one option (including its value) per line.
--
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]