Mark parent tag in DependencyInsight when dependency is inherited#6693
Merged
Mark parent tag in DependencyInsight when dependency is inherited#6693
Conversation
When a dependency is inherited from an external parent POM, the <parent> tag should be marked by DependencyInsight. Currently only <dependency> tags are marked. Reproducer for moderneinc/customer-requests#1803
When a dependency is inherited from a parent POM (rather than declared directly in the current POM), DependencyInsight now marks the <parent> tag with the matching dependencies. This fixes the issue where preconditions like IsLikelySpringFramework would fail when Spring dependencies were only present through parent inheritance. Fixes moderneinc/customer-requests#1803
Verifies that when a child POM declares its own dependency (even with version from parent's dependencyManagement), only the <dependency> tag is marked, not the <parent> tag.
A target dependency might be reachable through multiple "direct" dependencies in Maven's resolution (e.g., spring-core via both spring-boot-starter-web and spring-web). The parent tag should only be marked if the target is NOT reachable through any declared dependency. Changed the algorithm to: 1. Collect all targets and track which are "covered" by declared deps 2. Only mark parent with targets that aren't covered Added test for transitive dependency coming from child's declared dependency.
Contributor
Author
|
verified on my reference project that this now marks the parent tag -> change will be detected. |
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.
Summary
DependencyInsightto mark the<parent>tag when matching dependencies are inherited from parent POMsProblem
When Spring dependencies are declared in an external parent POM (not part of the project being analyzed),
DependencyInsightcouldn't find them because it only marked<dependency>tags. When there's no<dependency>tag in the child POM for a dependency inherited from the parent, nothing got marked, and preconditions likeIsLikelySpringFrameworkfailed.This caused the
SpringToSpringBootrecipe to skip processing when Spring dependencies came solely from parent inheritance.Solution
Modified
DependencyInsight.MarkIndividualDependencyto also check and mark<parent>tags:<parent>tag, collect all target dependencies that are NOT reachable through any declared<dependency>in the current POMspring-corevia bothspring-boot-starter-webandspring-web) - if ANY path goes through a declared dependency, don't mark the parent for that targetTest plan
Existing tests pass
Added
findDependencyDeclaredInProjectParent- parent declares dependency, child inherits → child's<parent>tag is markedAdded
doNotMarkParentTagWhenDependencyDeclaredInChild- child declares the target directly → only<dependency>tag is markedAdded
doNotMarkParentTagWhenTransitiveDependencyComesFromChildDeclaredDependency- child declares dependency that transitively brings target → only<dependency>tag is markedFixes moderneinc/customer-requests#1803