openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.26k stars 338 forks source link

org.openrewrite.maven.AddProperty addToRootPom flag #3895

Closed jpraet closed 7 months ago

jpraet commented 10 months ago

What problem are you trying to solve?

I want to add a maven property to the root pom only. org.openrewrite.maven.AddProperty adds the property to all poms.

Describe the solution you'd like

addToRootPom flag, like for org.openrewrite.maven.AddManagedDependency.

Have you considered any alternatives or workarounds?

trustParent=true doesn't work for my use case.

timtebeek commented 10 months ago

Thanks for the suggestion @jpraet ! I guess the best way forward here is to use preconditions, with a recipe that detects whether or not it's applied to the root pom. That way we don't have to add options to various Maven recipes, but can reuse that precondition across recipes instead.

sambsnyd commented 7 months ago

That feels like a reasonable improvement to make, I will look into it