GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix #12931: do not rewrite unmodified POMs in mvnup apply by kalayciburak · Pull Request #12938 · apache/maven

Conversation

@kalayciburak

@kalayciburak kalayciburak commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

mvnup apply always logged Saving modified POMs... and wrote every discovered POM, even when every strategy reported 0 POM(s) modified. That both misleads the user and rewrites files that did not change.

UpgradeResult already tracks modifiedPoms. Apply now:

  • writes only those POMs
  • skips the save report entirely when the set is empty

This answers the question on the issue: previously yes, unmodified files were rewritten; they are not anymore.

Fixes #12931

Checklist

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
  • Run mvn verify to make sure basic checks pass.
  • You have run the Core IT successfully.
  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

Test plan

Executed:

mvn -pl impl/maven-cli test -Dtest=AbstractUpgradeGoalTest,ApplyTest,CheckTest,UpgradeResultTest,StrategyOrchestratorTest

Result: 48 tests, 0 failures (includes new shouldNotRewriteOrReportWhenNoneModified and shouldWriteOnlyModifiedPoms).

Also executed:

mvn -pl impl/maven-cli test

Result: 665 tests, 0 failures, 2 skipped.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kalayciburak
Fix apache#12931: do not rewrite unmodified POMs in mvnup apply
ed2b870
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.
@slachiewicz slachiewicz added the bug Something isn't working label Aug 30, 2026
elharo
elharo reviewed Aug 30, 2026
View reviewed changes
Comment thread .../maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/AbstractUpgradeGoal.java
* Delegates to StrategyOrchestrator for coordinated strategy execution.
*/
protected int doUpgrade(UpgradeContext context, String targetModel, Map<Path, Document> pomMap) {
protected UpgradeResult doUpgrade(UpgradeContext context, String targetModel, Map<Path, Document> pomMap) {

@elharo elharo Aug 30, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

published signature change. when was this method introduced?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kalayciburak kalayciburak Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected int since 4.0.0-rc-6, mvnup only (not maven-api). nothing overrides it. return is UpgradeResult now so apply can skip unmodified poms. can switch back to int if you want.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .../maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/AbstractUpgradeGoal.java Outdated
*/
protected void saveModifications(UpgradeContext context, Map<Path, Document> pomMap) {
protected void saveModifications(UpgradeContext context, Map<Path, Document> pomMap, Set<Path> modifiedPoms) {
if (modifiedPoms.isEmpty()) {

@elharo elharo Aug 30, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to just not call this method if nothing was modified

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kalayciburak kalayciburak Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, skip the call when modifiedPoms is empty

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
HDPark95
HDPark95 reviewed Aug 30, 2026
View reviewed changes

@HDPark95 HDPark95 left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measured both trees (maven:3.9-temurin-21): 665 green at ed2b870, and reverting only AbstractUpgradeGoal.java fails exactly the 2 new tests.

Worth pinning: AbstractUpgradeStrategy.apply catches a throwing strategy and returns failure(pomMap.keySet(), Set.of()), so errorPoms is empty and success() is true. Probe (strategy edits a/pom.xml, then throws): master rc=0 with the partial edit written, here rc=0 and it is dropped. Dropping is safer, but rc should be 1.

The Path.of(".") branch is unreachable: execute() returns 0 on an empty pomMap before doUpgrade. All 665 stay green without it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gnodet
gnodet approved these changes Aug 30, 2026
View reviewed changes

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped fix that correctly threads the existing UpgradeResult.modifiedPoms set through to the save logic, skipping unmodified POMs and the "Saving modified POMs..." log when nothing changed.

Observations (informational):

  • Good use of the already-tracked modifiedPoms rather than inventing a new tracking mechanism
  • Tests cover both the zero-modification case (verifies last-modified-time unchanged and no save log) and the partial-modification case (multi-module selective write)
  • The return type change from int to UpgradeResult for doUpgrade is a sound refactoring that makes the API more expressive

📋 PR Metadata

Aspect Current Suggested
Milestone (none) 4.1.0

🔀 Backport Status

⚠️ maven-4.0.x has the mvnup code and should receive this fix. maven-3.9.x and maven-3.10.x do not contain mvnup, so no backport is needed for those branches.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@kalayciburak
Don't call saveModifications when no POM was modified
106987f
Skip the save path in execute when modifiedPoms is empty, instead of
returning early inside saveModifications.
@gnodet gnodet added this to the 4.1.0 milestone Aug 31, 2026
@gnodet
gnodet merged commit d963d18 into apache:master Aug 31, 2026
22 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned gnodet Aug 31, 2026
@gnodet gnodet mentioned this pull request Aug 31, 2026
[Backport maven-4.0.x] Fix #12931: do not rewrite unmodified POMs in mvnup apply #12972
Merged
gnodet added a commit that referenced this pull request Aug 31, 2026
@gnodet @kalayciburak
Fix #12931: do not rewrite unmodified POMs in mvnup apply (#12938) (#…
d17092e
…12972)

* 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.

Co-authored-by: Burak Kalaycı <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@elharo elharo elharo left review comments
@gnodet gnodet gnodet approved these changes
+1 more reviewer
@HDPark95 HDPark95 HDPark95 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

bug Something isn't working

Projects

None yet

Milestone

4.2.0

Development

Successfully merging this pull request may close these issues.

mvnup reports saving modified pom's while not change a thing

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@kalayciburak @gnodet @elharo @HDPark95 @slachiewicz
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.