arturobernalg opened a new pull request, #13400:
URL: https://github.com/apache/maven/pull/13400

   Fixes #7682
   
   A test dependency should only override a transitive dependency of the 
application while testing. Core collected the direct dependencies of every 
scope into a single graph, so with `a:2.0 -> b:2.0` and a test-scoped `b:1.0`, 
nearest-wins mediation kept `b:1.0` and the compile and runtime class paths 
ended up without `b`.
   
   - The direct dependencies of the test scopes (`test`, `test-only`, 
`test-runtime`) are left out of the graph of a mojo which does not ask for the 
test scope.
   - The dependencies are resolved for the scopes each mojo asks for, instead 
of once for the union of all the mojos of the build (the results are cached per 
combination of scopes). `compiler:compile` gets `a:2.0` and `b:2.0`, while 
`compiler:testCompile` and surefire still get `a:2.0` and `b:1.0`.
   - The declared dependency artifacts of a project are only updated from a 
resolution that included their scope, so the graph of the application cannot 
overwrite a test dependency.
   
   Maven Resolver is not changed. The resolution scopes introduced for MNG-8041 
were not used for this: they leave out every scope which is not on the path, 
including a direct `provided` dependency, which would break overriding a 
transitive dependency as `provided` to keep it out of a WAR (MNG-1233).
   
   This changes what two existing ITs asserted: `MavenITmng4789` and 
`MavenITmng1895#testitDirectVsIndirect` expected a direct test dependency to 
remove the transitive dependency from the compile and runtime class paths. Only 
their test-scope assertions are updated; the other rules about a direct versus 
a transitive scope (`provided`, `runtime`, scope widening) are unchanged and 
still pass.
   
   Tests:
   - `LifecycleDependencyResolverTest` resolves the compile, runtime and test 
scopes of a project in turn.
   - New `MavenITmng6058TestScopeMediationTest`, with the compile, test and 
runtime mojos of a single build.
   - `maven-impl` and `maven-core` tests, and the ITs about scopes, conflicts, 
classpaths and reactor resolution.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [ ] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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