elharo commented on code in PR #12938:
URL: https://github.com/apache/maven/pull/12938#discussion_r3889511735
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/AbstractUpgradeGoal.java:
##########
@@ -189,21 +190,21 @@ public int execute(UpgradeContext context) throws
Exception {
context.info("Found " + pomMap.size() + " POM file(s)");
// Perform the upgrade logic
- int result = doUpgrade(context, targetModel, pomMap);
+ UpgradeResult result = doUpgrade(context, targetModel, pomMap);
// Save modifications if this is an apply goal
- if (shouldSaveModifications() && result == 0) {
- saveModifications(context, pomMap);
+ if (shouldSaveModifications() && result.success()) {
+ saveModifications(context, pomMap, result.modifiedPoms());
}
- return result;
+ return result.success() ? 0 : 1;
}
/**
* Performs the upgrade logic using the strategy pattern.
* 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) {
Review Comment:
published signature change. when was this method introduced?
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/AbstractUpgradeGoal.java:
##########
@@ -230,13 +232,21 @@ protected int doUpgrade(UpgradeContext context, String
targetModel, Map<Path, Do
/**
* Saves the modified documents to disk using domtrip's perfect formatting
preservation.
+ * Unmodified POMs are left untouched and are not reported as saved.
*/
- protected void saveModifications(UpgradeContext context, Map<Path,
Document> pomMap) {
+ protected void saveModifications(UpgradeContext context, Map<Path,
Document> pomMap, Set<Path> modifiedPoms) {
+ if (modifiedPoms.isEmpty()) {
Review Comment:
better to just not call this method if nothing was modified
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]