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.

Relationship with Java compiler standard location

This enumeration is closely related to the JavaFileManager.Location enumerations. A difference is that the latter enumerates input and output files, while JavaPathType enumerates only input dependencies. Another difference is that JavaPathType contains some enumeration values used only at runtime and therefore not available in javax.tool, such as agent paths.
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. The Java tools location is StandardLocation.CLASS_PATH.

      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. The Java tools location is StandardLocation.MODULE_PATH.

      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. The Java tools location is StandardLocation.UPGRADE_MODULE_PATH.
    • PATCH_MODULE

      public static final JavaPathType PATCH_MODULE
      The path identified by the Java --patch-module option. The Java tools location is StandardLocation.PATCH_MODULE_PATH. 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. The Java tools location is StandardLocation.ANNOTATION_PROCESSOR_PATH.
    • PROCESSOR_MODULES

      public static final JavaPathType PROCESSOR_MODULES
      The path identified by the Java --processor-module-path option. The Java tools location is StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH.
    • 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. The Java tools location is DocumentationTool.Location.DOCLET_PATH.
    • TAGLETS

      public static final JavaPathType TAGLETS
      The path identified by the Javadoc -tagletpath option. The Java tools location is DocumentationTool.Location.TAGLET_PATH.
  • 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()
      Returns the unique name of this path type.
      Specified by:
      id in interface PathType
      Returns:
      the programmatic name of this enumeration value
      See Also:
    • location

      public Optional<JavaFileManager.Location> location()
      Returns the identification of this path in the javax.tool API. The value may be an instance of StandardLocation or DocumentationTool.Location, depending which tool will use this location.
      Returns:
      the javax.tool enumeration value corresponding to this JavaPathType
    • valueOf

      public static Optional<JavaPathType> valueOf(JavaFileManager.Location location)
      Returns the path type associated to the given javax.tool location. This method is the converse of location().
      Parameters:
      location - identification of a path in the javax.tool API
      Returns:
      Java path type associated to the given location
    • 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 array if there is no path element
      Throws:
      IllegalStateException - if no option is associated to this path type
    • toString

      public String toString()
      Returns a string representation of this path type for debugging purposes..
      Specified by:
      toString in interface PathType
      Overrides:
      toString in class Enum<JavaPathType>
      Returns:
      a string representation of this path type for debugging purposes