Skip to content

Fix AddProperty skipping property when child POM has relativePath#6943

Open
MBoegers wants to merge 1 commit intomainfrom
MBoegers/maven-relpath-fix
Open

Fix AddProperty skipping property when child POM has relativePath#6943
MBoegers wants to merge 1 commit intomainfrom
MBoegers/maven-relpath-fix

Conversation

@MBoegers
Copy link
Contributor

@MBoegers MBoegers commented Mar 11, 2026

Summary

  • Fixes AddProperty blindly deferring to parent POM whenever <relativePath> has a non-empty value, even when the property doesn't exist locally

  • This caused UpgradeDependencyVersion to fail when a managed dependency property needed to be overridden in a child POM that had a local parent inheriting the property from a remote ancestor (e.g. Spring Boot)

  • Root cause fix: guard the consolidation branch with parentValue != null so it only fires when the property already exists in the current POM

  • Related to UpgradeDependencyVersion bug not working in the absence of <relativePath> #6910 — this addresses the root cause in AddProperty rather than working around it in UpgradeDependencyVersion

Test plan

  • AddPropertyTest.addPropertyWhenLocalParentDoesNotDefineIt — child with relativePath, property not defined locally → property gets added
  • AddPropertyTest.consolidatesToParentWhenBothDefineProperty — both parent and child define property → child's property removed, parent updated
  • AddPropertyTest.addPropertyToChildWithImplicitRelativePath — no explicit <relativePath> tag → property added to both (no deferring)
  • UpgradeDependencyVersionTest.upgradeVersionDefinedViaImplicitPropertyInRemoteParentOfLocalParent_withRelativePath — end-to-end integration test
  • All existing AddPropertyTest, ChangePropertyValueTest, and UpgradeDependencyVersionTest tests pass

…ePath

AddProperty blindly deferred to parent whenever <relativePath> had a
non-empty value, even when the property didn't exist locally. This
caused UpgradeDependencyVersion to fail when a managed dependency
property needed to be overridden in a child POM with a local parent
that itself inherited the property from a remote ancestor.

Guard the consolidation branch with `parentValue != null` so it only
fires when the property already exists in the current POM (something
to actually consolidate), and falls through to AddPropertyVisitor
otherwise.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 11, 2026
@MBoegers MBoegers marked this pull request as ready for review March 12, 2026 09:55
@MBoegers MBoegers added the recipe Requested Recipe label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Requested Recipe

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant