Skip to content

Ignore spurious transitive exclusions when detecting redundant dependencies#191

Draft
timtebeek wants to merge 2 commits into
mainfrom
tim/redundant-deps-exclusions
Draft

Ignore spurious transitive exclusions when detecting redundant dependencies#191
timtebeek wants to merge 2 commits into
mainfrom
tim/redundant-deps-exclusions

Conversation

@timtebeek

Copy link
Copy Markdown
Member

RemoveRedundantDependencies compares 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, on spring-boot-starter-jersey a directly-declared jakarta.ws.rs:jakarta.ws.rs-api was kept as "redundant with different exclusions" because the transitive copy had a spurious jakarta.activation-api exclusion 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).

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant