This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch maven-3.9.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-3.9.x by this push:
new 5a552315f [MNG-7713] Make Maven fail if option present (#1021)
5a552315f is described below
commit 5a552315f16fe1c209da94d83147a27b0d537774
Author: Tamas Cservenak <[email protected]>
AuthorDate: Wed Mar 1 13:30:04 2023 +0100
[MNG-7713] Make Maven fail if option present (#1021)
As with previous PR (simple removal) the `-llr` got
interpreted as `-l lr`, it logged all output to `lr`
file. This would maean that use of `-llr` would still
sneakily 'work' and probably cause surprise down the
road to users.
Returned the option, and expicitly checking for it's
presence to be able to fail with meaningful message.
---
https://issues.apache.org/jira/browse/MNG-7713
---
.../src/main/java/org/apache/maven/cli/CLIManager.java | 6 ++++++
.../src/main/java/org/apache/maven/cli/MavenCli.java | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
index 8790539be..bc62f64b7 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java
@@ -280,6 +280,12 @@ public class CLIManager {
.desc("Ineffective, only kept for backward compatibility")
.build());
+ // Adding this back to make Maven fail if used
+ options.addOption(Option.builder("llr")
+ .longOpt("legacy-local-repository")
+ .desc("UNSUPPORTED: Use of this option will make Maven
invocation fail.")
+ .build());
+
options.addOption(Option.builder()
.longOpt(COLOR)
.hasArg()
diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
index b7e937234..fa667e9a0 100644
--- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
+++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
@@ -362,6 +362,17 @@ public class MavenCli {
cliManager.displayHelp(System.out);
throw e;
}
+
+ // check for presence of unsupported command line options
+ try {
+ if (cliRequest.commandLine.hasOption("llr")) {
+ throw new UnrecognizedOptionException("Option '-llr' is not
supported starting with Maven 3.9.1");
+ }
+ } catch (ParseException e) {
+ System.err.println("Unsupported options: " + e.getMessage());
+ cliManager.displayHelp(System.out);
+ throw e;
+ }
}
private void informativeCommands(CliRequest cliRequest) throws
ExitException {