Enum Class DirectoryHierarchy

java.lang.Object
java.lang.Enum<DirectoryHierarchy>
org.apache.maven.plugin.compiler.DirectoryHierarchy
All Implemented Interfaces:
Serializable, Comparable<DirectoryHierarchy>, Constable

public enum DirectoryHierarchy extends Enum<DirectoryHierarchy>
The way that source files are organized in a file system directory hierarchy. Directory hierarchies are package hierarchy, module hierarchy and module source hierarchy, but for the purpose of the Maven Compiler Plugin we do not distinguish between the two latter.
See Also:
  • Enum Constant Details

    • PACKAGE

      public static final DirectoryHierarchy PACKAGE
      Project using package hierarchy. This is the hierarchy used by all Java projects before Java 9. Note that it does not necessarily implies a class-path project. A modular project can still use the package hierarchy if the project contains only one module.
    • PACKAGE_WITH_MODULE

      @Deprecated public static final DirectoryHierarchy PACKAGE_WITH_MODULE
      Deprecated.
      Used only for compatibility with Maven 3.
      Project using package hierarchy, but in which a module-info file has been detected. This is used for compilation of tests. For the main code, we pretend that the hierarchy is MODULE_SOURCE and move the directory output after compilation. Therefore, this enumeration value can be understood as "pseudo module source hierarchy".
      See Also:
      • ModuleDirectoryRemover
    • MODULE_SOURCE

      public static final DirectoryHierarchy MODULE_SOURCE
      A multi-module project using module source hierarchy. It could also be a module hierarchy, as the Maven Compiler Plugin does not need to distinguish module hierarchy and module source hierarchy.
  • Method Details

    • values

      public static DirectoryHierarchy[] 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 DirectoryHierarchy 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
    • outputDirectoryForReleases

      public Path outputDirectoryForReleases(Path outputDirectory)
      Returns the directory where to write the compiled class files for all Java releases. The standard path for PACKAGE hierarchy is META-INF/versions. The caller shall add the version number to the returned path.
      Parameters:
      outputDirectory - usually the value of SourceDirectory.outputDirectory
      Returns:
      the directory for all versions
    • outputDirectoryForReleases

      public Path outputDirectoryForReleases(Path outputDirectory, SourceVersion release)
      Returns the directory where to write the compiled class files for a specific Java release. The standard path is META-INF/versions/${release} where ${release} is the numerical value of the release argument. However for MODULE_SOURCE case, the returned path is rather META-INF/versions-modular/${release}. The latter is non-standard because there is no standard multi-module JAR formats as of 2025. The use of "versions-modular" is for allowing other plugins such as Maven JAR plugin to avoid confusion with the standard case.
      Parameters:
      outputDirectory - usually the value of SourceDirectory.outputDirectory
      release - the release, or null for the default release
      Returns:
      the directory for the classes of the specified version
    • toString

      public String toString()
      Returns a string representation for use in error message.
      Overrides:
      toString in class Enum<DirectoryHierarchy>
      Returns:
      human-readable string representation