Conversation
…-during-change-dependency
pom.xml that is not referenced in parent pom.xml is not updated when child dependency runs ChangeDependencyChangeDependencyGroupIdAndArtifactId does not update properties in parent pom
3 tasks
…-during-change-dependency
rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyGroupIdAndArtifactId.java
Show resolved
Hide resolved
Contributor
Author
|
There's obviously a lot of changes, but in general it seems to be doing what it needs to. |
…-during-change-dependency
Member
|
As discussed with Jonathan I'll do a last pass over this one before we merge, since we already use the same pattern elsewhere and can resolve the immediate need with this change. In the near term we'd want to revisit this recipe and others like it to extract traits, as we're increasingly seeing complicated logic in each of the Maven (and Gradle) dependency recipes, with subtle variations that might best to pulled out of the recipes and handled once. |
…-during-change-dependency
timtebeek
approved these changes
Aug 11, 2025
3 tasks
dcsekar
pushed a commit
to dcsekar/rewrite
that referenced
this pull request
Aug 18, 2025
…parent pom (openrewrite#5815) * Adding example showcasing problem * Impl * Apply suggestion from @github-actions[bot] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Polish * Polish * Polish * Polish * Polish * Polish * Fix retain versions for UpgradeDependencyVersion * Polish * Polish * Polish * Polish * Polish * Minor polish --------- Co-authored-by: lingenj <jacob.van.lingen@moderne.io> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Tim te Beek <tim@moderne.io>
dcsekar
pushed a commit
to dcsekar/rewrite
that referenced
this pull request
Aug 18, 2025
…ties in parent pom (openrewrite#5815) (openrewrite#5903) * Revert "`ChangeDependencyGroupIdAndArtifactId` does not update properties in parent pom (openrewrite#5815)" This reverts commit faf51f5. * Minimize diff in revert --------- Co-authored-by: Tim te Beek <tim@moderne.io>
MBoegers
added a commit
that referenced
this pull request
Jan 29, 2026
…parent POMs Convert `ChangeDependencyGroupIdAndArtifactId` from `Recipe` to `ScanningRecipe` so that version properties defined in parent POMs are updated when the dependency referencing that property is in a child POM. The scanner phase identifies version properties inherited from parent POMs and records which source file defines each property. The visitor phase then applies property updates when visiting those parent POM files. All existing visitor logic is preserved unchanged, avoiding the recipe-chaining issues that caused the previous attempt (#5815) to be reverted. Fixes moderneinc/customer-requests#1374
3 tasks
MBoegers
added a commit
that referenced
this pull request
Jan 29, 2026
…parent POMs Convert `ChangeDependencyGroupIdAndArtifactId` from `Recipe` to `ScanningRecipe` so that version properties defined in parent POMs are updated when the dependency referencing that property is in a child POM. The scanner phase identifies version properties inherited from parent POMs and records which source file defines each property. The visitor phase then applies property updates when visiting those parent POM files. All existing visitor logic is preserved unchanged, avoiding the recipe-chaining issues that caused the previous attempt (#5815) to be reverted. Fixes moderneinc/customer-requests#1374
timtebeek
added a commit
that referenced
this pull request
Feb 17, 2026
…parent POMs (#6630) * `ChangeDependencyGroupIdAndArtifactId` updates version properties in parent POMs Convert `ChangeDependencyGroupIdAndArtifactId` from `Recipe` to `ScanningRecipe` so that version properties defined in parent POMs are updated when the dependency referencing that property is in a child POM. The scanner phase identifies version properties inherited from parent POMs and records which source file defines each property. The visitor phase then applies property updates when visiting those parent POM files. All existing visitor logic is preserved unchanged, avoiding the recipe-chaining issues that caused the previous attempt (#5815) to be reverted. Fixes moderneinc/customer-requests#1374 * Add test for shared property overlap scenario Verifies that when a property in a parent POM is shared by multiple dependencies in a child POM, and only one dependency matches the change criteria, the property is left unchanged and the version is inlined instead. * Check sibling modules for overlapping property usage When a version property in a parent POM is shared by dependencies across different child modules, changing it would break non-matching siblings. The existing overlap filter only checked the current module's children and parent dependencies, but not sibling modules. Walk up the parent chain and check each parent's children to detect property usage conflicts in sibling modules. When overlap is found, the version is inlined instead of updating the shared property. * Add test documenting conservative behavior for redefined child properties When a child module redefines a parent property used by a non-matching dependency, the overlap filter conservatively prevents updating the parent property. This is safe because ChangePropertyValue via doAfterVisit does not scope to a single document and would also change the child's intentional override. * Avoid traversal when newVersion or compartor is null * Add an early return after handling property tag --------- Co-authored-by: Tim te Beek <tim@moderne.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
The
ChangeDependencyGroupIdAndArtifactIdrecipe can also use properties defined a parent pom.What's your motivation?
Having version's defined in a parent pom is quite common. Other recipes like
UpgradeDependencyVersiondo already support this.Additional context
Most of the changes consist of moving all the visitor code into the scanning phase, so we can determine which actions have to be done (whether it is changing properties, creating, remove or changing values). Then in the actual visitor phase we apply these changes accordingly.
Checklist