Skip to content

Commit

Permalink
Fix version display (fixes #838)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 17, 2023
1 parent 2cd9eaf commit 8dfc265
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
20 changes: 13 additions & 7 deletions daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ public int doMain(CliRequest cliRequest, Map<String, String> 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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
20 changes: 13 additions & 7 deletions daemon-m40/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ public int doMain(CliRequest cliRequest, Map<String, String> 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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 8dfc265

Please sign in to comment.