Enum Class JavaPathType

java.lang.Object
java.lang.Enum<JavaPathType>
org.apache.maven.api.JavaPathType
All Implemented Interfaces:
Serializable, Comparable<JavaPathType>, Constable, PathType

@Experimental public enum JavaPathType extends Enum<JavaPathType> implements PathType
The option of a Java command-line tool where to place the paths to some dependencies. A PathType can identify the class-path, the module-path, the patches for a specific module, or another kind of path.

One path type is handled in a special way: unlike other options, the paths specified in a --patch-module Java option is effective only for a specified module. This type is created by calls to patchModule(String) and a new instance must be created for every module to patch.

Path types are often exclusive. For example, a dependency should not be both on the Java class-path and on the Java module-path.

Since:
4.0.0
See Also:
  • Enum Constant Details

    • CLASSES

      public static final JavaPathType CLASSES
      The path identified by the Java --class-path option. Used for compilation, execution and Javadoc among others.

      Context-sensitive interpretation: A dependency with this path type will not necessarily be placed on the class-path. There are two circumstances where the dependency may nevertheless be placed somewhere else:

      • If MODULES path type is also set, then the dependency can be placed either on the class-path or on the module-path, but only one of those. The choice is up to the plugin, possibly using heuristic rules (Maven 3 behavior).
      • If a patchModule(String) is also set and the main JAR file is placed on the module-path, then the test dependency will be placed on the Java --patch-module option instead of the class-path.
    • MODULES

      public static final JavaPathType MODULES
      The path identified by the Java --module-path option. Used for compilation, execution and Javadoc among others.

      Context-sensitive interpretation: A dependency with this flag will not necessarily be placed on the module-path. There are two circumstances where the dependency may nevertheless be placed somewhere else:

      • If CLASSES path type is also set, then the dependency should be placed on the module-path, but is also compatible with placement on the class-path. Compatibility can be achieved, for example, by repeating in the META-INF/services/ directory the services that are declared in the module-info.class file. In that case, the path type can be chosen by the plugin.
      • If a patchModule(String) is also set and the main JAR file is placed on the module-path, then the test dependency will be placed on the Java --patch-module option instead of the --module-path option.
    • UPGRADE_MODULES

      public static final JavaPathType UPGRADE_MODULES
      The path identified by the Java --upgrade-module-path option.
    • PATCH_MODULE

      public static final JavaPathType PATCH_MODULE
      The path identified by the Java --patch-module option. Note that this option is incomplete, because it must be followed by a module name. Use this type only when the module to patch is unknown.
      See Also:
    • PROCESSOR_CLASSES

      public static final JavaPathType PROCESSOR_CLASSES
      The path identified by the Java --processor-path option.
    • PROCESSOR_MODULES

      public static final JavaPathType PROCESSOR_MODULES
      The path identified by the Java --processor-module-path option.
    • AGENT

      public static final JavaPathType AGENT
      The path identified by the Java -agentpath option.
    • DOCLET

      public static final JavaPathType DOCLET
      The path identified by the Javadoc -doclet option.
    • TAGLETS

      public static final JavaPathType TAGLETS
      The path identified by the Javadoc -tagletpath option.
  • Method Details

    • values

      public static JavaPathType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JavaPathType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • patchModule

      @Nonnull public static JavaPathType.Modular patchModule(@Nonnull String moduleName)
      Creates a path identified by the Java --patch-module option. Contrarily to the other types of paths, this path is applied to only one specific module. Used for compilation and execution among others.

      Context-sensitive interpretation: This path type makes sense only when a main module is added on the module-path by another dependency. In no main module is found, the patch dependency may be added on the class-path or module-path depending on whether CLASSES or MODULES is present.

      Parameters:
      moduleName - name of the module on which to apply the path
      Returns:
      an identification of the patch-module path for the given module.
      See Also:
    • id

      public String id()
      Description copied from interface: PathType
      Returns the unique name of this path type, including the module to patch if any. For example, if this type is MODULES, then this method returns "MODULES". But if this type was created by JavaPathType.patchModule("foo.bar"), then this method returns "PATCH_MODULE:foo.bar".
      Specified by:
      id in interface PathType
      Returns:
      the programmatic name together with the module name on which it applies
      See Also:
    • option

      @Nonnull public Optional<String> option()
      Returns the name of the tool option for this path. For example, if this path type is MODULES, then this method returns "--module-path". The option does not include the module name on which it applies.
      Specified by:
      option in interface PathType
      Returns:
      the name of the tool option for this path type
    • option

      @Nonnull public String option(Iterable<? extends Path> paths)
      Returns the option followed by a string representation of the given path elements. For example, if this type is MODULES, then the option is "--module-path" followed by the specified path elements.
      Specified by:
      option in interface PathType
      Parameters:
      paths - the path to format as a tool option
      Returns:
      the option associated to this path type followed by the given path elements, or an empty string if there is no path element
      Throws:
      IllegalStateException - if no option is associated to this path type
    • toString

      public String toString()
      Description copied from interface: PathType
      Returns a string representation for this extensible enum describing a path type. For example "PathType[PATCH_MODULE:foo.bar]".
      Specified by:
      toString in interface PathType
      Overrides:
      toString in class Enum<JavaPathType>