gnodet-bot commented on code in PR #13871:
URL: https://github.com/apache/maven/pull/13871#discussion_r4495587301


##########
compat/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java:
##########
@@ -190,10 +191,24 @@ public CLIManager() {
                 .desc(
                         "Do not recurse into sub-projects. When used together 
with -pl, do not recurse into sub-projects of selected aggregators")
                 .build());
+
+        // -U is now an alias for --update-all.
         options.addOption(Option.builder(Character.toString(UPDATE_SNAPSHOTS))
+                .longOpt("update-all")
+                .desc("Forces updates of artifacts and metadata on remote 
repositories")
+                .build());
+
+        // Keep the old option as a deprecated alias for backwards 
compatibility.
+        options.addOption(Option.builder()

Review Comment:
   ⚠️ **Deprecated alias is not functionally connected to `-U`.**
   
   This new standalone option (no short option char) is registered separately 
from `-U`/`--update-all`. When a user invokes `mvn --update-snapshots`, 
`commandLine.hasOption(CLIManager.UPDATE_SNAPSHOTS)` (the `'U'` char check in 
`MavenCli.populateRequest`) returns `false` — the deprecated option silently 
does nothing except emit the deprecation warning, without triggering the actual 
update behavior.
   
   The fix is to handle `"update-snapshots"` explicitly in 
`MavenCli.populateRequest` (see the comment on the `MavenCli.java` hunk).



##########
compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java:
##########
@@ -1395,6 +1395,7 @@ private MavenExecutionRequest populateRequest(CliRequest 
cliRequest, MavenExecut
         disableOnPresentOption(commandLine, CLIManager.NON_RECURSIVE, 
request::setRecursive);
         enableOnPresentOption(commandLine, CLIManager.OFFLINE, 
request::setOffline);
         enableOnPresentOption(commandLine, CLIManager.UPDATE_SNAPSHOTS, 
request::setUpdateSnapshots);
+        enableOnPresentOption(commandLine, update-snapshots, 
request::setUpdatedSnapshots);

Review Comment:
   🚨 **Compile error — will not build.** `update-snapshots` is not a valid Java 
identifier (hyphens are illegal outside strings), and `setUpdatedSnapshots` 
does not exist on `MavenExecutionRequest`.
   
   To handle the deprecated `--update-snapshots` alias as a functional synonym, 
use:
   ```suggestion
           enableOnPresentOption(commandLine, "update-snapshots", 
request::setUpdateSnapshots);
   ```



-- 
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]

Reply via email to