mcc0nnell opened a new pull request, #13066: URL: https://github.com/apache/maven/pull/13066
Summary Fixes MNG-1378 for Maven 4 by making a producer’s direct test-scoped dependencies available when that producer is consumed as a dependency of type test-jar. Maven’s normal test scope remains non-transitive. The change is deliberately artifact-specific: the scope selector is wrapped with a parent-aware selector that permits test dependencies only while collecting the children of a test-jar artifact. Ordinary JAR dependencies keep the existing behavior. Why A test-jar is a separate artifact with its own classpath requirements. Its classes may depend on libraries declared with scope=test in the producer POM, but those libraries are currently dropped when another project consumes the test JAR. As a result, consumers must manually duplicate dependencies that are already part of the producer’s test classpath. This is the behavior reported by MNG-1378. Implementation The change adds a TestJarDependencySelector around Maven’s existing scope selector. The selector is parent-aware: when Resolver descends into a dependency whose artifact type is exactly test-jar, direct test-scoped children are allowed through. Everywhere else, dependency selection delegates unchanged to Maven’s existing scope rules. The implementation does not: * make Maven’s test scope generally transitive; * rewrite producer POMs; * change ordinary JAR dependency behavior; * change Maven-3-personality behavior. Compatibility The behavior change applies only to Maven 4 semantics. Maven-3-personality mode keeps the existing selector unchanged. This avoids changing long-established Maven 3 dependency behavior while allowing Maven 4 to give test-jar artifacts a dependency graph that matches their actual classpath requirements. Tests This PR adds a Core IT regression fixture with four modules: * support — an ordinary dependency; * test-jar — produces a test JAR and depends on support with scope=test; * consumer — depends only on the producer’s test-jar and must receive both the test JAR and support; * regular-consumer — depends on the producer’s ordinary JAR and must not receive support. The producer artifacts are installed before the consumers are resolved separately, so the test exercises repository artifact-descriptor resolution rather than relying only on an in-reactor model. Checklist * [x] This pull request addresses one issue: MNG-1378. * [x] The pull request description explains what changes, how, and why. * [x] The branch contains one focused commit with a meaningful subject and body. * [x] A behavioral Core IT regression fixture is included and is expected to fail without the runtime change. * [ ] mvn verify has been run successfully. * [ ] Core IT has been run successfully. License * [x] I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004. Draft until Maven CI and Core IT validation are complete. -- 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]
