Interface SourceRoot

All Known Implementing Classes:
DefaultSourceRoot

public interface SourceRoot
A root directory of source files. The sources may be Java main classes, test classes, resources or anything else identified by the scope.

Default values

The properties in this interface are defined in the <Source> element of the Maven project descriptor. For each property, the default value is either empty or documented in the project descriptor.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Path
    Returns the root directory where the sources are stored.
    default boolean
    Returns whether the directory described by this source element should be included in the build.
    default List<String>
    Returns the list of patterns for the files to exclude.
    default List<String>
    Returns the list of patterns for the files to include.
    default Language
    Returns the language of the source files.
    matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes)
    Returns a matcher combining the include and exclude patterns.
    default Optional<String>
    Returns the name of the Java module (or other language-specific module) which is built by the sources.
    default ProjectScope
    Returns in which context the source files will be used.
    default boolean
    Returns whether resources are filtered to replace tokens with parameterized values.
    default Optional<Path>
    Returns an explicit target path, overriding the default value.
    default Optional<Version>
    Returns the version of the platform where the code will be executed.
  • Method Details

    • directory

      default Path directory()
      Returns the root directory where the sources are stored.. The path is relative to the POM file.

      Default implementation

      The default value depends on whether a module name is specified in this source root: The default value is relative. Implementation may override with absolute path instead.
      Returns:
      the root directory where the sources are stored
    • includes

      default List<String> includes()
      Returns the list of patterns for the files to include.. The path separator is / on all platforms, including Windows. The prefix before the : character, if present and longer than 1 character, is the syntax. If no syntax is specified, or if its length is 1 character (interpreted as a Windows drive), the default is a Maven-specific variation of the "glob" pattern.

      The default implementation returns an empty list, which means to apply a language-dependent pattern. For example, for the Java language, the pattern includes all files with the .java suffix.

      Returns:
      the list of patterns for the files to include
      See Also:
    • excludes

      default List<String> excludes()
      Returns the list of patterns for the files to exclude.. The exclusions are applied after the inclusions. The default implementation returns an empty list.
      Returns:
      the list of patterns for the files to exclude
    • matcher

      PathMatcher matcher(Collection<String> defaultIncludes, boolean useDefaultExcludes)
      Returns a matcher combining the include and exclude patterns.. If the user did not specify any includes, the given defaultIncludes are used. These defaults depend on the plugin. For example, the default include of the Java compiler plugin is "**/*.java".

      If the user did not specify any excludes, the default is often files generated by Source Code Management (SCM) software or by the operating system. Examples: "**/.gitignore", "**/.DS_Store".

      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

      default ProjectScope scope()
      Returns in which context the source files will be used.. Not to be confused with dependency scope. The default value is "main".
      Returns:
      in which context the source files will be used
      See Also:
    • language

      default Language language()
      Returns the language of the source files.. The default value is "java".
      Returns:
      the language of the source files
      See Also:
    • module

      default Optional<String> module()
      Returns the name of the Java module (or other language-specific module) which is built by the sources.. The default value is empty.
      Returns:
      the name of the Java module (or other language-specific module) which is built by the sources
    • targetVersion

      default Optional<Version> targetVersion()
      Returns the version of the platform where the code will be executed.. In a Java environment, this is the value of the --release compiler option. The default value is empty.
      Returns:
      the version of the platform where the code will be executed
    • targetPath

      default Optional<Path> targetPath()
      Returns an explicit target path, overriding the default value.. When a target path is explicitly specified, the values of the module() and targetVersion() elements are not used for inferring the path (they are still used as compiler options however). It means that for scripts and resources, the files below the path specified by directory() are copied to the path specified by targetPath() with the exact same directory structure.
      Returns:
      an explicit target path, overriding the default value
    • stringFiltering

      default boolean stringFiltering()
      Returns whether resources are filtered to replace tokens with parameterized values.. The default value is false.
      Returns:
      whether resources are filtered to replace tokens with parameterized values
    • enabled

      default boolean enabled()
      Returns whether the directory described by this source element should be included in the build.. The default value is true.
      Returns:
      whether the directory described by this source element should be included in the build