Ignore spurious transitive exclusions when detecting redundant dependencies#191
Draft
timtebeek wants to merge 2 commits into
Draft
Ignore spurious transitive exclusions when detecting redundant dependencies#191timtebeek wants to merge 2 commits into
timtebeek wants to merge 2 commits into
Conversation
…encies A dependency's effective exclusions are resolved within the matched parent's whole tree, so they can be polluted by exclusions other branches declare against artifacts the coordinate could never bring on its own (e.g. an optional dependency pruned elsewhere). Comparing these raw sets against a clean direct declaration made the recipe keep genuinely redundant dependencies. Filter each transitive's effective exclusions down to artifacts in the coordinate's own dependency closure, dropping no-op exclusions before the comparison. This only ever drops exclusions that change nothing, so it never causes an unsafe removal.
Share the POM download/resolve path between resolveTransitivesFromPom and dependencyClosure via resolvePom/withMavenCentral helpers, and hoist the closure cache onto the Accumulator so it survives across source files in a multi-module build.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RemoveRedundantDependenciescompares each transitively-provided dependency's effective exclusions against the direct declaration's, but a coordinate's effective exclusions are resolved within the matched parent's whole tree, so they can be polluted by exclusions other branches declare against artifacts the coordinate could never bring on its own (e.g. an optional dependency pruned elsewhere). For example, onspring-boot-starter-jerseya directly-declaredjakarta.ws.rs:jakarta.ws.rs-apiwas kept as "redundant with different exclusions" because the transitive copy had a spuriousjakarta.activation-apiexclusion misattributed from a sibling.This filters each transitive's effective exclusions down to artifacts actually in that coordinate's own dependency closure, dropping no-op exclusions before the comparison; because it only ever drops exclusions that change nothing, it never causes an unsafe removal. Added regression tests covering the removed-when-equivalent case (
jakarta.ws.rs-api), the kept-when-genuinely-different case (jersey-client), and removed-when-exclusions-match for a real transitive exclusion (tomcat-embed-core).