Skip to content

Support changing properties in Maven profiles#7031

Draft
MBoegers wants to merge 2 commits intomainfrom
mboegers/change-property-in-profiles
Draft

Support changing properties in Maven profiles#7031
MBoegers wants to merge 2 commits intomainfrom
mboegers/change-property-in-profiles

Conversation

@MBoegers
Copy link
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
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