Skip to content

Commit

Permalink
JAVA_HOME should be documented as discriminating #852
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed May 23, 2023
1 parent 82e42e6 commit 7d9a39b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>mvnd</code>
* executable is located
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static String displayHelp(CLIManager cliManager) {
spaces(help, indentPos - help.length());
wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);

if (env.isDiscriminating()) {
if (env.isDocumentedAsDiscriminating()) {
indentedLine(help, terminalWidth, "This is a discriminating start parameter.", indent);
}
if (env.getDefault() != null) {
Expand Down

0 comments on commit 7d9a39b

Please sign in to comment.