[Backport maven-4.0.x] Fix #12931: do not rewrite unmodified POMs in mvnup apply - #12972
Merged
Conversation
* Fix #12931: do not rewrite unmodified POMs in mvnup apply mvnup apply always logged "Saving modified POMs..." and wrote every discovered POM, even when no strategy reported changes. Save only the POMs in UpgradeResult.modifiedPoms and skip the save report when that set is empty. * Don't call saveModifications when no POM was modified Skip the save path in execute when modifiedPoms is empty, instead of returning early inside saveModifications.
gnodet
commented
Aug 31, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
✅ Looks Good
Clean backport of #12938 (merged to master) to maven-4.0.x. The diff is byte-for-byte identical to the original.
Technical notes:
- The change from returning
inttoUpgradeResultindoUpgradecorrectly exposesmodifiedPoms()to the caller without breakingApplyorChecksubclasses. - The exception-handling path constructs
UpgradeResult.failure()with emptymodifiedPoms, preventingsaveModificationsfrom being called on failure — correct behavior. - Tests use
FileTimecomparison to verify unmodified POMs are not rewritten (not just that the method isn't called) — robust assertion strategy. - No backport to 3.x branches needed —
mvnupis a Maven 4 feature.
🤖 This review was generated by ForgeBot.
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.
Backport of #12938 to
maven-4.0.x.Summary
mvnup applyalways loggedSaving modified POMs...and wrote every discovered POM, even when every strategy reported0 POM(s) modified. That both misleads the user and rewrites files that did not change.UpgradeResultalready tracksmodifiedPoms. Apply now:Fixes #12931