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 5e82a79e94..41cb71a829 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 4f3acf4bfd..047f675fd4 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 {