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 TypeMethodDescriptionboolean
addComaSeparated
(String option, String values, Collection<String> valids, UnaryOperator<String[]> filter) Adds the given option using theoption:values
syntax wherevalues
is a coma-separated list.boolean
addIfNonBlank
(String option, String value) Adds the given option if a non-null and non-blank value is provided and if the option is supported.boolean
Adds the given option if the given value is true and the option is supported.boolean
addMemoryValue
(String option, String label, String value, boolean addDefaultUnit) Verifies the validity of the given memory setting and adds it as an option.void
addUnchecked
(Iterable<String> arguments) Adds the non-null and non-empty elements without verifying their validity.
-
Method Details
-
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, ornull
or 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:values
syntax wherevalues
is 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, ornull
for not appending the option.- Parameters:
option
- the option (e.g.-g
)values
- coma-separated values of the option, ornull
if nonevalids
- valid values for better error message when needed, ornull
if unspecifiedfilter
- filter to apply on the values before to add them, ornull
if 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, ornull
if 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, ornull
or empty if none
-