Skip to content

Support escaping property placeholders with backslash#6817

Merged
MBoegers merged 7 commits intomainfrom
mboegers/work-1874
Mar 3, 2026
Merged

Support escaping property placeholders with backslash#6817
MBoegers merged 7 commits intomainfrom
mboegers/work-1874

Conversation

@MBoegers
Copy link
Copy Markdown
Contributor

Summary

  • Add backslash escape support to PropertyPlaceholderHelper: writing \${...} in recipe YAML preserves the literal ${...} in the output instead of resolving it as a placeholder
  • Update ChangePluginConfiguration.configuration @Option description to document the escape syntax
  • Fixes an issue where Maven property references like ${java.version} in ChangePluginConfiguration were resolved at recipe load time instead of being preserved literally

Test plan

  • PropertyPlaceholderHelperTest: 6 new tests covering escaped placeholders, mixed escaped/resolved, regression for unresolved left as-is, normal resolution, and backslash preservation
  • ChangePluginConfigurationTest: 2 new tests for Maven property references via direct construction and YAML loading with escape syntax
  • Full ./gradlew build -x javadoc passes (361 tasks, 0 failures)

When recipe YAML contains Maven property references like ${java.version}
in parameter values, the YamlResourceLoader resolves them as property
placeholders at load time. This prevents users from passing literal
${...} references through to recipe parameters.

Add escape support: doubling the first character of the placeholder
prefix (e.g., writing $${java.version} for the ${ prefix) produces
a literal ${java.version} in the resolved output.

Fixes moderneinc/customer-requests#1874
When recipe YAML contains Maven property references like ${java.version}
in parameter values, the YamlResourceLoader resolves them as property
placeholders at load time. This prevents users from passing literal
${...} references through to recipe parameters.

Add escape support: a backslash before the placeholder prefix (e.g.,
writing \${java.version} for the ${ prefix) produces a literal
${java.version} in the resolved output.

Fixes moderneinc/customer-requests#1874
Document the \${...} escape syntax in the ChangePluginConfiguration
@option description so users know how to pass literal Maven property
references.

Add regression tests to ensure existing behavior is preserved:
- Unresolved placeholders are left as-is
- Normal resolution still works
- Backslashes not before a placeholder prefix are preserved
@MBoegers MBoegers marked this pull request as ready for review February 25, 2026 16:10
@MBoegers MBoegers moved this from In Progress to Ready to Review in OpenRewrite Feb 26, 2026
@MBoegers MBoegers merged commit e402269 into main Mar 3, 2026
1 check passed
@MBoegers MBoegers deleted the mboegers/work-1874 branch March 3, 2026 12:06
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants