Class DefaultSourceRoot

java.lang.Object
org.apache.maven.impl.DefaultSourceRoot
All Implemented Interfaces:
org.apache.maven.api.SourceRoot

public final class DefaultSourceRoot extends Object implements org.apache.maven.api.SourceRoot
A default implementation of SourceRoot built from the model.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultSourceRoot(Path baseDir, org.apache.maven.api.ProjectScope scope, org.apache.maven.api.model.Resource resource)
    Creates a new instance from the given resource.
    DefaultSourceRoot(org.apache.maven.api.ProjectScope scope, org.apache.maven.api.Language language, Path directory)
    Creates a new instance for the given directory and scope.
    DefaultSourceRoot(org.apache.maven.api.ProjectScope scope, org.apache.maven.api.Language language, Path directory, List<String> includes, List<String> excludes)
    Creates a new instance for the given directory and scope.
    DefaultSourceRoot(org.apache.maven.api.Session session, Path baseDir, org.apache.maven.api.model.Source source)
    Creates a new instance from the given model.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the root directory where the sources are stored.
    boolean
    Returns whether the directory described by this source element should be included in the build.
    boolean
    Returns whether the two objects are of the same class with equal property values.
    Returns the patterns for the files to exclude.
    int
    Returns a hash code value computed from all properties.
    Returns the patterns for the files to include.
    org.apache.maven.api.Language
    Returns the language of the source files.
    matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes)
    Returns a matcher combining the include and exclude patterns.
    Returns the name of the Java module (or other language-specific module) which is built by the sources.
    org.apache.maven.api.ProjectScope
    Returns in which context the source files will be used.
    boolean
    Returns whether resources are filtered to replace tokens with parameterized values.
    Returns an explicit target path, overriding the default value.
    Optional<org.apache.maven.api.Version>
    Returns the version of the platform where the code will be executed.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultSourceRoot

      public DefaultSourceRoot(org.apache.maven.api.Session session, Path baseDir, org.apache.maven.api.model.Source source)
      Creates a new instance from the given model.
      Parameters:
      session - the session of resolving extensible enumerations
      baseDir - the base directory for resolving relative paths
      source - a source element from the model
    • DefaultSourceRoot

      public DefaultSourceRoot(Path baseDir, org.apache.maven.api.ProjectScope scope, org.apache.maven.api.model.Resource resource)
      Creates a new instance from the given resource. This is used for migration from the previous way of declaring resources.
      Parameters:
      baseDir - the base directory for resolving relative paths
      scope - the scope of the resource (main or test)
      resource - a resource element from the model
    • DefaultSourceRoot

      public DefaultSourceRoot(org.apache.maven.api.ProjectScope scope, org.apache.maven.api.Language language, Path directory)
      Creates a new instance for the given directory and scope.
      Parameters:
      scope - scope of source code (main or test)
      language - language of the source code
      directory - directory of the source code
    • DefaultSourceRoot

      public DefaultSourceRoot(org.apache.maven.api.ProjectScope scope, org.apache.maven.api.Language language, Path directory, List<String> includes, List<String> excludes)
      Creates a new instance for the given directory and scope.
      Parameters:
      scope - scope of source code (main or test)
      language - language of the source code
      directory - directory of the source code
      includes - patterns for the files to include, or null or empty if unspecified
      excludes - patterns for the files to exclude, or null or empty if nothing to exclude
  • Method Details

    • directory

      public Path directory()
      Returns the root directory where the sources are stored..
      Specified by:
      directory in interface org.apache.maven.api.SourceRoot
      Returns:
      the root directory where the sources are stored
    • includes

      public List<String> includes()
      Returns the patterns for the files to include..
      Specified by:
      includes in interface org.apache.maven.api.SourceRoot
      Returns:
      the patterns for the files to include
    • excludes

      public List<String> excludes()
      Returns the patterns for the files to exclude..
      Specified by:
      excludes in interface org.apache.maven.api.SourceRoot
      Returns:
      the patterns for the files to exclude
    • matcher

      public PathMatcher matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes)
      Returns a matcher combining the include and exclude patterns..
      Specified by:
      matcher in interface org.apache.maven.api.SourceRoot
      Parameters:
      defaultIncludes - the default includes if unspecified by the user
      useDefaultExcludes - whether to add the default set of patterns to exclude, mostly Source Code Management (SCM) files
      Returns:
      a matcher combining the include and exclude patterns
    • scope

      public org.apache.maven.api.ProjectScope scope()
      Returns in which context the source files will be used..
      Specified by:
      scope in interface org.apache.maven.api.SourceRoot
      Returns:
      in which context the source files will be used
    • language

      public org.apache.maven.api.Language language()
      Returns the language of the source files..
      Specified by:
      language in interface org.apache.maven.api.SourceRoot
      Returns:
      the language of the source files
    • module

      public Optional<String> module()
      Returns the name of the Java module (or other language-specific module) which is built by the sources..
      Specified by:
      module in interface org.apache.maven.api.SourceRoot
      Returns:
      the name of the Java module (or other language-specific module) which is built by the sources
    • targetVersion

      public Optional<org.apache.maven.api.Version> targetVersion()
      Returns the version of the platform where the code will be executed..
      Specified by:
      targetVersion in interface org.apache.maven.api.SourceRoot
      Returns:
      the version of the platform where the code will be executed
    • targetPath

      public Optional<Path> targetPath()
      Returns an explicit target path, overriding the default value..
      Specified by:
      targetPath in interface org.apache.maven.api.SourceRoot
      Returns:
      an explicit target path, overriding the default value
    • stringFiltering

      public boolean stringFiltering()
      Returns whether resources are filtered to replace tokens with parameterized values..
      Specified by:
      stringFiltering in interface org.apache.maven.api.SourceRoot
      Returns:
      whether resources are filtered to replace tokens with parameterized values
    • enabled

      public boolean enabled()
      Returns whether the directory described by this source element should be included in the build..
      Specified by:
      enabled in interface org.apache.maven.api.SourceRoot
      Returns:
      whether the directory described by this source element should be included in the build
    • hashCode

      public int hashCode()
      Returns a hash code value computed from all properties..
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value computed from all properties
    • equals

      public boolean equals(Object obj)
      Returns whether the two objects are of the same class with equal property values..
      Overrides:
      equals in class Object
      Parameters:
      obj - the other object to compare with this object, or null
      Returns:
      whether the two objects are of the same class with equal property values