From d62ecadb35dd4b9a39d9c219bfb53b032657e0f1 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 24 Oct 2024 13:51:57 +0200 Subject: [PATCH] [MNG-8348] Fix typos in deprecation warning message (#1844) --- .../maven/cling/invoker/CommonsCliOptions.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java index 471757ca4f..04ad3ebbd9 100644 --- a/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java +++ b/maven-cli/src/main/java/org/apache/maven/cling/invoker/CommonsCliOptions.java @@ -219,16 +219,22 @@ public abstract class CommonsCliOptions implements Options { printWriter.accept("Detected deprecated option use in " + source); for (Option option : cliManager.getUsedDeprecatedOptions()) { StringBuilder sb = new StringBuilder(); - sb.append("The option -").append(option.getOpt()); + sb.append("The option "); + if (option.getOpt() != null) { + sb.append("-").append(option.getOpt()); + } if (option.getLongOpt() != null) { - sb.append(",--").append(option.getLongOpt()); + if (option.getOpt() != null) { + sb.append(","); + } + sb.append("--").append(option.getLongOpt()); } sb.append(" is deprecated "); if (option.getDeprecated().isForRemoval()) { sb.append("and will be removed in a future version"); } if (option.getDeprecated().getSince() != null) { - sb.append("since ") + sb.append(" since ") .append(request.commandName()) .append(" ") .append(option.getDeprecated().getSince()); @@ -415,7 +421,7 @@ public abstract class CommonsCliOptions implements Options { // We need to eat any quotes surrounding arguments... String[] cleanArgs = CleanArgument.cleanArgs(args); DefaultParser parser = DefaultParser.builder() - .setDeprecatedHandler(usedDeprecatedOptions::add) + .setDeprecatedHandler(this::addDeprecatedOption) .build(); CommandLine commandLine = parser.parse(options, cleanArgs); // to trigger deprecation handler, so we can report deprecation BEFORE we actually use options @@ -423,6 +429,10 @@ public abstract class CommonsCliOptions implements Options { return commandLine; } + protected void addDeprecatedOption(Option option) { + usedDeprecatedOptions.add(option); + } + public org.apache.commons.cli.Options getOptions() { return options; }