This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new da64ee9c9 [MNG-7713] Make Maven fail if option present (#1021) (#1022)
da64ee9c9 is described below

commit da64ee9c9130e026fcbe80027c052171fd00ea49
Author: Tamas Cservenak <[email protected]>
AuthorDate: Wed Mar 1 13:51:51 2023 +0100

    [MNG-7713] Make Maven fail if option present (#1021) (#1022)
    
    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 5e82a79e9..41cb71a82 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
@@ -290,6 +290,12 @@ public class CLIManager {
                 .desc("Defines the color mode of the output. Supported are 
'auto', 'always', 'never'.")
                 .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());
+
         // Deprecated
         options.addOption(Option.builder()
                 .longOpt(DEBUG)
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 4f3acf4bf..047f675fd 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
@@ -374,6 +374,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 {

Reply via email to