Package org.apache.maven.plugin.compiler
Class Options
java.lang.Object
org.apache.maven.plugin.compiler.Options
An helper class for preparing the options to pass to the tool (compiler or document generator).
It does not include the options related to paths (class-path, destination directory, etc.).
If an option is unsupported by the tool, a message is logged at the warning level.
- Author:
- Martin Desruisseaux
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddComaSeparated(String option, String values, Collection<String> valids, UnaryOperator<String[]> filter) Adds the given option using theoption:valuessyntax wherevaluesis a coma-separated list.booleanaddIfNonBlank(String option, String value) Adds the given option if a non-null and non-blank value is provided and if the option is supported.booleanAdds the given option if the given value is true and the option is supported.booleanaddMemoryValue(String option, String label, String value, boolean addDefaultUnit) Verifies the validity of the given memory setting and adds it as an option.voidaddUnchecked(Iterable<String> arguments) Adds the non-null and non-empty elements without verifying their validity.booleansetRelease(String value) Adds or sets the value of the--releaseoption.toString()Returns a string representatation of the options for debugging purposes.
-
Method Details
-
setRelease
Adds or sets the value of the--releaseoption. If this option was not present, it is added. If this option has already been specified, then its value is changed to the given value if non-null and non-blank, or removed otherwise.- Parameters:
value- value of the--releaseoption, ornullor empty if none- Returns:
- whether the option has been added or defined
-
addIfTrue
Adds the given option if the given value is true and the option is supported. If the option is unsupported, then a warning is logged and the option is not added.- Parameters:
option- the option (e.g.--enable-preview)value- value of the option- Returns:
- whether the option has been added
-
addIfNonBlank
Adds the given option if a non-null and non-blank value is provided and if the option is supported. If the option is unsupported by the tool, then a warning is logged and the option is not added.- Parameters:
option- the option (e.g.,--release)value- value of the option, ornullor blank if none- Returns:
- whether the option has been added
-
addComaSeparated
public boolean addComaSeparated(String option, String values, Collection<String> valids, UnaryOperator<String[]> filter) Adds the given option using theoption:valuessyntax wherevaluesis a coma-separated list. The option is added only if at least one non-blank value is provided. Values are converted to lower cases. Leading and trailing spaces are removed. If a filter is specified, then that filter will receive the values specified by the users and shall return the values to append, ornullfor not appending the option.- Parameters:
option- the option (e.g.-g)values- coma-separated values of the option, ornullif nonevalids- valid values for better error message when needed, ornullif unspecifiedfilter- filter to apply on the values before to add them, ornullif none- Returns:
- whether the option has been added
-
addMemoryValue
Verifies the validity of the given memory setting and adds it as an option. If the value has no units and Maven defaults are enabled, appends "M" as the default units of measurement. Note: in the International System of Units, the symbol shall be upper-case "M". The lower-case "m" symbol is not correct as it stands for "milli".- Parameters:
option- the option (e.g.-J-Xms)label- name of the XML element or attribute, used only if a warning message needs to be producedvalue- the memory setting, ornullif noneaddDefaultUnit- whether to add a default unit (currently 'M') if none is provided- Returns:
- whether the option has been added
-
addUnchecked
Adds the non-null and non-empty elements without verifying their validity. This method is used for user-specified compiler arguments.- Parameters:
arguments- the arguments to add, ornullor empty if none
-
toString
Returns a string representatation of the options for debugging purposes.
-