[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
This commit is contained in:
Tamas Cservenak 2023-03-01 13:51:51 +01:00 committed by GitHub
parent afc1a2bd86
commit da64ee9c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -290,6 +290,12 @@ public class CLIManager {
.desc("Defines the color mode of the output. Supported are 'auto', 'always', 'never'.") .desc("Defines the color mode of the output. Supported are 'auto', 'always', 'never'.")
.build()); .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 // Deprecated
options.addOption(Option.builder() options.addOption(Option.builder()
.longOpt(DEBUG) .longOpt(DEBUG)

View File

@ -374,6 +374,17 @@ public class MavenCli {
cliManager.displayHelp(System.out); cliManager.displayHelp(System.out);
throw e; 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 { private void informativeCommands(CliRequest cliRequest) throws ExitException {