diff --git a/daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java b/daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java index ebc4dba07..7ddc25157 100644 --- a/daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java +++ b/daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java @@ -227,11 +227,11 @@ public int doMain(CliRequest cliRequest, Map clientEnv) throws E environment(cliRequest.workingDirectory, clientEnv); cli(cliRequest); properties(cliRequest); - help(cliRequest); logging(cliRequest); + informativeCommands(cliRequest); + version(cliRequest); container(cliRequest); configure(cliRequest, eventSpyDispatcher, configurationProcessors); - version(cliRequest); toolchains(cliRequest); populateRequest(cliRequest); encryption(cliRequest); @@ -296,11 +296,20 @@ void cli(CliRequest cliRequest) throws Exception { } } - private void help(CliRequest cliRequest) throws Exception { + private void informativeCommands(CliRequest cliRequest) throws Exception { if (cliRequest.commandLine.hasOption(CLIManager.HELP)) { buildEventListener.log(MvndHelpFormatter.displayHelp(newCLIManager())); throw new ExitException(0); } + + if (cliRequest.commandLine.hasOption(CLIManager.VERSION)) { + if (cliRequest.commandLine.hasOption(CLIManager.QUIET)) { + buildEventListener.log(CLIReportingUtils.showVersionMinimal()); + } else { + buildEventListener.log(CLIReportingUtils.showVersion()); + } + throw new ExitException(0); + } } private CLIManager newCLIManager() { @@ -416,11 +425,8 @@ void logging(CliRequest cliRequest) { } private void version(CliRequest cliRequest) throws ExitException { - if (cliRequest.debug || cliRequest.commandLine.hasOption(CLIManager.VERSION)) { + if (cliRequest.debug || cliRequest.commandLine.hasOption(CLIManager.SHOW_VERSION)) { buildEventListener.log(CLIReportingUtils.showVersion()); - if (cliRequest.commandLine.hasOption(CLIManager.VERSION)) { - throw new ExitException(0); - } } } diff --git a/daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java b/daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java index bda30f63d..1a8f84771 100644 --- a/daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java +++ b/daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java @@ -216,11 +216,11 @@ public int doMain(CliRequest cliRequest, Map clientEnv) throws E environment(cliRequest.workingDirectory, clientEnv); cli(cliRequest); properties(cliRequest); - help(cliRequest); logging(cliRequest); + informativeCommands(cliRequest); + version(cliRequest); container(cliRequest); configure(cliRequest, eventSpyDispatcher, configurationProcessors); - version(cliRequest); toolchains(cliRequest); populateRequest(cliRequest); encryption(cliRequest); @@ -285,11 +285,20 @@ void cli(CliRequest cliRequest) throws Exception { } } - private void help(CliRequest cliRequest) throws Exception { + private void informativeCommands(CliRequest cliRequest) throws Exception { if (cliRequest.commandLine.hasOption(CLIManager.HELP)) { buildEventListener.log(MvndHelpFormatter.displayHelp(newCLIManager())); throw new ExitException(0); } + + if (cliRequest.commandLine.hasOption(CLIManager.VERSION)) { + if (cliRequest.commandLine.hasOption(CLIManager.QUIET)) { + buildEventListener.log(CLIReportingUtils.showVersionMinimal()); + } else { + buildEventListener.log(CLIReportingUtils.showVersion()); + } + throw new ExitException(0); + } } private CLIManager newCLIManager() { @@ -400,11 +409,8 @@ void logging(CliRequest cliRequest) { } private void version(CliRequest cliRequest) throws ExitException { - if (cliRequest.verbose || cliRequest.commandLine.hasOption(CLIManager.VERSION)) { + if (cliRequest.verbose || cliRequest.commandLine.hasOption(CLIManager.SHOW_VERSION)) { buildEventListener.log(CLIReportingUtils.showVersion()); - if (cliRequest.commandLine.hasOption(CLIManager.VERSION)) { - throw new ExitException(0); - } } }