diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java index 63d299d78..c0892f741 100644 --- a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java +++ b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java @@ -76,8 +76,8 @@ public enum Environment { // // System properties // - /** Java home for starting the daemon */ - JAVA_HOME("java.home", "JAVA_HOME", null, OptionType.PATH, Flags.NONE), + /** Java home for starting the daemon. */ + JAVA_HOME("java.home", "JAVA_HOME", null, OptionType.PATH, Flags.DOCUMENTED_AS_DISCRIMINATING), /** * The daemon installation directory. The client normally sets this according to where its mvnd * executable is located @@ -346,7 +346,11 @@ public static String getProperty(String property) { this.property = property; this.environmentVariable = environmentVariable; this.default_ = default_ != null ? default_.toString() : null; - this.flags = flags; + if ((flags & Flags.DISCRIMINATING) != 0) { + this.flags = (flags | Flags.DOCUMENTED_AS_DISCRIMINATING); + } else { + this.flags = flags; + } this.type = type; if (options.length == 0) { this.options = Collections.emptyMap(); @@ -400,6 +404,10 @@ public boolean isDiscriminating() { return (flags & Flags.DISCRIMINATING) != 0; } + public boolean isDocumentedAsDiscriminating() { + return (flags & Flags.DOCUMENTED_AS_DISCRIMINATING) != 0; + } + public boolean isInternal() { return (flags & Flags.INTERNAL) != 0; } @@ -602,8 +610,15 @@ public String getJavaDoc() { static class Flags { private static final int NONE = 0b0; + /** + * Implies {@link #DOCUMENTED_AS_DISCRIMINATING} - this is implemented in + * {@link Environment#Environment(String, String, Object, OptionType, int, String...)} + */ private static final int DISCRIMINATING = 0b1; + private static final int INTERNAL = 0b10; private static final int OPTIONAL = 0b100; + /** Set automatically for entries having {@link #DISCRIMINATING} */ + private static final int DOCUMENTED_AS_DISCRIMINATING = 0b1000; } } diff --git a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java index 271836b00..95430aaa0 100644 --- a/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java +++ b/daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java @@ -121,8 +121,15 @@ public static String displayHelp(CLIManager cliManager) { spaces(help, indentPos - help.length()); wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent); - indentedLine(help, terminalWidth, "Default", env.getDefault(), indent); - indentedLine(help, terminalWidth, "Env. variable", env.getEnvironmentVariable(), indent); + if (env.isDocumentedAsDiscriminating()) { + indentedLine(help, terminalWidth, "This is a discriminating start parameter.", indent); + } + if (env.getDefault() != null) { + indentedLine(help, terminalWidth, "Default: " + env.getDefault(), indent); + } + if (env.getEnvironmentVariable() != null) { + indentedLine(help, terminalWidth, "Env. variable: " + env.getEnvironmentVariable(), indent); + } }); help.append(lineSeparator).append(lineSeparator).append("mvnd value types:"); @@ -151,14 +158,10 @@ private static int getTerminalWidth() { return terminalWidth; } - private static void indentedLine( - StringBuilder stringBuilder, int terminalWidth, String key, String value, String indent) { - int lineEnd; - if (value != null) { - lineEnd = stringBuilder.length() + terminalWidth; - stringBuilder.append(System.lineSeparator()).append(indent); - wrap(stringBuilder, key + ": " + value, terminalWidth, lineEnd, indent); - } + private static void indentedLine(StringBuilder stringBuilder, int terminalWidth, String text, String indent) { + final int lineEnd = stringBuilder.length() + terminalWidth; + stringBuilder.append(System.lineSeparator()).append(indent); + wrap(stringBuilder, text, terminalWidth, lineEnd, indent); } /**