Skip to content

Support changing properties in Maven profiles#7031

Merged
sambsnyd merged 2 commits intomainfrom
mboegers/change-property-in-profiles
Mar 31, 2026
Merged

Support changing properties in Maven profiles#7031
sambsnyd merged 2 commits intomainfrom
mboegers/change-property-in-profiles

Conversation

@MBoegers
Copy link
Copy Markdown
Contributor

@MBoegers MBoegers commented Mar 18, 2026

Summary

  • ChangePropertyValue now also matches properties defined in /project/profiles/profile/properties
  • Adds PROFILE_PROPERTY_MATCHER and isProfilePropertyTag() to MavenVisitor following the existing pattern for profile-scoped matchers

Problem

The ChangePropertyValue recipe only changes properties under /project/properties. Maven also allows property definitions inside profiles at /project/profiles/profile/properties. Customers using profile-scoped properties (e.g., sonar.host.url in a <profile>) were not getting their values updated.

Solution

Added a PROFILE_PROPERTY_MATCHER XPath matcher (/project/profiles/profile/properties/*) and isProfilePropertyTag() method to MavenVisitor, following the existing pattern used for dependencies, plugins, etc. Updated ChangePropertyValue to check both isPropertyTag() and isProfilePropertyTag().

Test plan

  • Existing tests pass

  • New test: property only in profile gets changed

  • New test: property in both project and profile gets changed in both locations

  • New test: unrelated profile properties are not changed

  • Fixes moderneinc/customer-requests#1798

Properties defined in project/profiles/profile/properties are not
currently changed by the ChangePropertyValue recipe. These tests
reproduce the issue reported in moderneinc/customer-requests#1798.
ChangePropertyValue only matched properties under /project/properties.
Maven also allows properties in /project/profiles/profile/properties.

Add PROFILE_PROPERTY_MATCHER and isProfilePropertyTag() to MavenVisitor
following the existing pattern for profile-scoped matchers, and use it
in ChangePropertyValue.

Fixes moderneinc/customer-requests#1798
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 18, 2026
@MBoegers MBoegers marked this pull request as ready for review March 26, 2026 10:45
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Mar 31, 2026
@sambsnyd sambsnyd merged commit e26d5de into main Mar 31, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Mar 31, 2026
@sambsnyd sambsnyd deleted the mboegers/change-property-in-profiles branch March 31, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants