wilx opened a new pull request, #1671:
URL: https://github.com/apache/maven-dependency-plugin/pull/1671

   ## Summary
   
   - make `dependency:tree` prune a dependency matching `excludes` together 
with its complete subtree
   - apply exclusions before includes, so an include cannot restore a node 
beneath an excluded subtree
   - retain ancestor paths for included nodes that remain after exclusion 
pruning
   - document the behavior and add unit and integration coverage for pruning, 
sibling traversal, and combined filters
   
   ## Root cause
   
   The existing implementation combined `includes` and `excludes` into one node 
filter and applied it through `FilteringDependencyNodeVisitor`. A rejected node 
was omitted from the serialized output, but its children were still traversed. 
When includes were also present, the ancestor-or-self pass could restore paths 
through nodes that had matched an exclude pattern.
   
   This change introduces a pruning visitor. A rejected node returns `false` 
from `visit`, preventing traversal of its children, while its matching 
`endVisit` returns `true` so traversal continues with the node's next sibling. 
The visitor remembers the acceptance decision made at the start of the visit so 
the delegate receives balanced `visit`/`endVisit` callbacks without evaluating 
the filter twice.
   
   ## Semantics and compatibility
   
   This intentionally changes the output-filtering semantics of 
`dependency:tree`:
   
   - `excludes` is a structural pruning operation. A matching node and every 
node below it are absent from the serialized tree.
   - `includes` is a positive filter over the tree that remains after pruning. 
It selects matching dependencies and retains the ancestor paths needed to reach 
them.
   - exclusions take precedence; includes cannot override them.
   - this affects only serialization of the dependency tree and does not change 
dependency collection or resolution.
   
   As discussed in #1334, the current parameter names do not describe these 
distinct roles especially well. Names such as `filter` for the path-preserving 
positive selection and `exclusions` for subtree pruning would communicate the 
behavior more clearly. This PR retains the established `includes` and 
`excludes` names for CLI and plugin-configuration compatibility. Introducing 
aliases, deprecating the existing names, or renaming them should be considered 
separately as an API migration.
   
   ## Validation
   
   - `mvn spotless:apply`
   - Maven 3: `mvn verify` — 412 tests passed, 1 skipped
   - Maven 3: `mvn -Prun-its verify` — 99 integration-test projects passed
   - Maven 4: `mvn verify` — 412 tests passed, 1 skipped
   - Maven 4: `mvn -Prun-its verify` — 98 integration-test projects passed, 1 
skipped due to its Maven-version condition
   - Spring Web Services 4.0.11 reproducer with the snapshot plugin, both 
normal and `-Dverbose=true`: excluding `org.glassfish.jaxb:jaxb-runtime` also 
removes `jaxb-core`, `txw2`, and `istack-commons-runtime`
   
   Fixes #1427
   
   Fixes #1334
   
   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
   - [x] Your pull request should address just one issue, without pulling in 
other changes.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line 
and body.
     Note that commits might be squashed by a maintainer on merge.
   - [x] Write unit tests that match behavioral changes, where the tests fail 
if the changes to the runtime are not applied.
     This may not always be possible but is a best-practice.
   - [x] Run `mvn verify` to make sure basic checks pass.
     A more thorough check will be performed on your pull request automatically.
   - [x] You have run the integration tests successfully (`mvn -Prun-its 
verify`).
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
   - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   - [ ] In any other case, please file 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