Restore dependency management for child modules of a local parent#8082
Draft
timtebeek wants to merge 1 commit into
Draft
Restore dependency management for child modules of a local parent#8082timtebeek wants to merge 1 commit into
timtebeek wants to merge 1 commit into
Conversation
When ChangeParentPom (and UpgradeParentVersion) upgrades a parent that drops management of a dependency, it restores the dropped versions as local dependency management. Previously it only considered dependencies declared by the pom whose parent was being changed, so in a multi-module project where a local parent declares the upgraded parent and the child modules declare the affected dependencies, nothing was restored and the modules failed to resolve. Also inspect descendant modules that inherit from the pom being changed, so management dropped by the new parent is restored in the local parent on behalf of the child modules that declare those dependencies without an explicit version. Fixes moderneinc/customer-requests#2589
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
ChangeParentPom/UpgradeParentVersionnow restore dropped dependency management in a local parent on behalf of the child modules that declare those dependencies, not just the parent's own dependencies.Problem
When upgrading a parent (e.g. Spring Boot 2.7 → 3.0), the recipe restores dependency management for dependencies that the new parent no longer manages. It only looked at dependencies declared by the pom whose
<parent>was being changed.In a multi-module project where a local parent declares the upgraded parent (e.g.
spring-boot-starter-parent) and the child modules declare the affected dependencies without an explicit version, nothing was restored — the local parent declares none of those dependencies itself, and the child modules' direct parent (the local parent) isn't what's being changed. The result was unresolvable dependencies and module resolution errors after the upgrade.Solution
In addition to the pom being changed, also inspect descendant modules that inherit from it (gathered from the scanning accumulator's resolution markers). Dependency management that the new parent drops is restored in the local parent on behalf of any descendant module that declares the dependency without an explicit version. Restored entries are de-duplicated by
groupId:artifactId. Single-module behavior is unchanged.Note for reviewers
The added test asserts the management is restored in the local parent (the fix). The child module additionally renders a transient
No version provided for direct dependency ...warning marker: within a single run the child's in-memory model isn't re-resolved against the local parent's newly-added management (cross-module model propagation here is order-dependent, and only the parent version is propagated through the resolution markers today). This marker is not written to the pom file and is present onmainfor this scenario as well; it clears on the next parse, so the resulting build resolves correctly. Making that propagation order-independent would be a larger, separate change to the multi-module marker machinery.Test plan
Existing
ChangeParentPomTest/UpgradeParentVersionTestpassNew
ChangeParentPomTest.RetainVersions#bringsDownRemovedManagedVersionDeclaredInChildModuleOfLocalParentfails onmain, passes with the fixFixes moderneinc/customer-requests#2589