Class Options

java.lang.Object
org.apache.maven.plugin.compiler.Options

public final class Options extends Object
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 Details

    • addIfTrue

      public boolean addIfTrue(String option, boolean value)
      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

      public 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. 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, or null 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 the option:values syntax where values 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, or null for not appending the option.
      Parameters:
      option - the option (e.g. -g)
      values - coma-separated values of the option, or null if none
      valids - valid values for better error message when needed, or null if unspecified
      filter - filter to apply on the values before to add them, or null if none
      Returns:
      whether the option has been added
    • addMemoryValue

      public boolean addMemoryValue(String option, String label, String value, boolean addDefaultUnit)
      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 produced
      value - the memory setting, or null if none
      addDefaultUnit - whether to add a default unit (currently 'M') if none is provided
      Returns:
      whether the option has been added
    • addUnchecked

      public void addUnchecked(Iterable<String> arguments)
      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, or null or empty if none