You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2025/08/29 13:58:47 UTC
(maven) branch maven-4.0.x updated: Maven Upgrade Tool: remove unused --force and --yes options (Fixes #11001) (#11066) (#11079)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new f8ed84c396 Maven Upgrade Tool: remove unused --force and --yes options (Fixes #11001) (#11066) (#11079)
f8ed84c396 is described below
commit f8ed84c396e4619097bbc31a825e96374a2bf31c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Aug 29 15:58:42 2025 +0200
Maven Upgrade Tool: remove unused --force and --yes options (Fixes #11001) (#11066) (#11079)
* Remove unused --force and --yes options from mvnup tool
Fixes #11001
The mvnup tool displayed --force and --yes options in its help output,
but these options were never actually used by the tool. The 'apply' goal
always saves modifications without prompting, making these options
misleading to users.
Changes:
- Removed force() and yes() methods from UpgradeOptions API interface
- Removed CLI option parsing for --force/-f and --yes/-y in CommonsCliUpgradeOptions
- Removed help text for these options from both CommonsCliUpgradeOptions.displayHelp() and Help goal
- Removed test that verified these options were included in help output
The mvnenc (encryption) tool continues to use its own force() and yes()
methods as those are actually functional in that context.
(cherry picked from commit 4b686c5e7acd0ce3b01ff1625615934822c08c46)
---
.../apache/maven/api/cli/mvnup/UpgradeOptions.java | 14 ----------
.../invoker/mvnup/CommonsCliUpgradeOptions.java | 30 ----------------------
.../maven/cling/invoker/mvnup/goals/Help.java | 2 --
.../maven/cling/invoker/mvnup/goals/HelpTest.java | 11 --------
4 files changed, 57 deletions(-)
diff --git a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnup/UpgradeOptions.java b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnup/UpgradeOptions.java
index 47d8a67cbe..96aa7a99fb 100644
--- a/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnup/UpgradeOptions.java
+++ b/api/maven-api-cli/src/main/java/org/apache/maven/api/cli/mvnup/UpgradeOptions.java
@@ -33,20 +33,6 @@
*/
@Experimental
public interface UpgradeOptions extends Options {
- /**
- * Should the operation be forced (ie overwrite existing files, if any).
- *
- * @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
- */
- Optional<Boolean> force();
-
- /**
- * Should imply "yes" to all questions.
- *
- * @return an {@link Optional} containing the boolean value {@code true} if specified, or empty
- */
- Optional<Boolean> yes();
-
/**
* Returns the list of upgrade goals to be executed.
* These goals can include operations like "check", "dependencies", "plugins", etc.
diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/CommonsCliUpgradeOptions.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/CommonsCliUpgradeOptions.java
index 0e5621c288..d3f668c899 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/CommonsCliUpgradeOptions.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/CommonsCliUpgradeOptions.java
@@ -44,24 +44,6 @@ protected CommonsCliUpgradeOptions(String source, CLIManager cliManager, Command
super(source, cliManager, commandLine);
}
- @Override
- @Nonnull
- public Optional<Boolean> force() {
- if (commandLine.hasOption(CLIManager.FORCE)) {
- return Optional.of(Boolean.TRUE);
- }
- return Optional.empty();
- }
-
- @Override
- @Nonnull
- public Optional<Boolean> yes() {
- if (commandLine.hasOption(CLIManager.YES)) {
- return Optional.of(Boolean.TRUE);
- }
- return Optional.empty();
- }
-
@Override
@Nonnull
public Optional<List<String>> goals() {
@@ -143,8 +125,6 @@ public void displayHelp(ParserRequest request, Consumer<String> printStream) {
printStream.accept(" --plugins Upgrade plugins known to fail with Maven 4");
printStream.accept(
" -a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
- printStream.accept(" -f, --force Overwrite files without asking for confirmation");
- printStream.accept(" -y, --yes Answer \"yes\" to all prompts automatically");
printStream.accept("");
printStream.accept("Default behavior: --model and --plugins are applied if no other options are specified");
printStream.accept("");
@@ -157,8 +137,6 @@ protected CommonsCliUpgradeOptions copy(
}
protected static class CLIManager extends CommonsCliOptions.CLIManager {
- public static final String FORCE = "f";
- public static final String YES = "y";
public static final String MODEL_VERSION = "m";
public static final String DIRECTORY = "d";
public static final String INFER = "i";
@@ -169,14 +147,6 @@ protected static class CLIManager extends CommonsCliOptions.CLIManager {
@Override
protected void prepareOptions(org.apache.commons.cli.Options options) {
super.prepareOptions(options);
- options.addOption(Option.builder(FORCE)
- .longOpt("force")
- .desc("Should overwrite without asking any configuration?")
- .build());
- options.addOption(Option.builder(YES)
- .longOpt("yes")
- .desc("Should imply user answered \"yes\" to all incoming questions?")
- .build());
options.addOption(Option.builder(MODEL_VERSION)
.longOpt("model-version")
.hasArg()
diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/Help.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/Help.java
index 0915da66d7..f06e46c3d6 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/Help.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/Help.java
@@ -54,8 +54,6 @@ public int execute(UpgradeContext context) throws Exception {
context.info(" --plugins Upgrade plugins known to fail with Maven 4");
context.info(
"-a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)");
- context.info("-f, --force Overwrite files without asking for confirmation");
- context.info("-y, --yes Answer \"yes\" to all prompts automatically");
context.unindent();
context.println();
context.info("Default behavior: --model and --plugins are applied if no other options are specified");
diff --git a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/HelpTest.java b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/HelpTest.java
index 0809d5f313..cfe5b7839e 100644
--- a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/HelpTest.java
+++ b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/HelpTest.java
@@ -103,15 +103,4 @@ void testHelpIncludesDefaultBehavior() throws Exception {
Mockito.verify(context.logger)
.info("Default behavior: --model and --plugins are applied if no other options are specified");
}
-
- @Test
- void testHelpIncludesForceAndYesOptions() throws Exception {
- UpgradeContext context = createMockContext();
-
- help.execute(context);
-
- // Verify that --force and --yes options are included
- Mockito.verify(context.logger).info(" -f, --force Overwrite files without asking for confirmation");
- Mockito.verify(context.logger).info(" -y, --yes Answer \"yes\" to all prompts automatically");
- }
}