Class DefaultPathMatcherFactory

java.lang.Object
org.apache.maven.impl.DefaultPathMatcherFactory
All Implemented Interfaces:
Service, PathMatcherFactory

@Named @Singleton public class DefaultPathMatcherFactory extends Object implements PathMatcherFactory
Default implementation of PathMatcherFactory that creates PathSelector instances for filtering files based on include/exclude patterns.

This implementation provides Maven's traditional include/exclude pattern behavior, compatible with Maven 3 plugins like maven-compiler-plugin and maven-clean-plugin.

Since:
4.0.0
  • Constructor Details

    • DefaultPathMatcherFactory

      public DefaultPathMatcherFactory()
  • Method Details

    • createPathMatcher

      @Nonnull public PathMatcher createPathMatcher(@Nonnull Path baseDirectory, Collection<String> includes, Collection<String> excludes, boolean useDefaultExcludes)
      Description copied from interface: PathMatcherFactory
      Creates a path matcher for filtering files based on include and exclude patterns.

      The pathnames used for matching will be relative to the specified base directory and use '/' as separator, regardless of the hosting operating system.

      Specified by:
      createPathMatcher in interface PathMatcherFactory
      Parameters:
      baseDirectory - the base directory for relativizing paths during matching
      includes - the patterns of files to include, or null/empty for including all files
      excludes - the patterns of files to exclude, or null/empty for no exclusion
      useDefaultExcludes - whether to augment excludes with default SCM exclusion patterns
      Returns:
      a PathMatcher that can be used to test if paths should be included
    • createExcludeOnlyMatcher

      @Nonnull public PathMatcher createExcludeOnlyMatcher(@Nonnull Path baseDirectory, Collection<String> excludes, boolean useDefaultExcludes)
      Description copied from interface: PathMatcherFactory
      Creates a path matcher that includes all files except those matching the exclude patterns.

      This is equivalent to calling PathMatcherFactory.createPathMatcher(Path, Collection, Collection, boolean) with includes = null.

      Specified by:
      createExcludeOnlyMatcher in interface PathMatcherFactory
      Parameters:
      baseDirectory - the base directory for relativizing paths during matching
      excludes - the patterns of files to exclude, or null/empty for no exclusion
      useDefaultExcludes - whether to augment excludes with default SCM exclusion patterns
      Returns:
      a PathMatcher that can be used to test if paths should be included
    • deriveDirectoryMatcher

      @Nonnull public PathMatcher deriveDirectoryMatcher(@Nonnull PathMatcher fileMatcher)
      Description copied from interface: PathMatcherFactory
      Returns a filter for directories that may contain paths accepted by the given matcher. The given path matcher should be an instance created by this service. The path matcher returned by this method expects directory paths. If that matcher returns false, then the directory will definitively not contain the paths selected by the matcher given in argument to this method. In such case, the whole directory and all its sub-directories can be skipped. In case of doubt, or if the matcher given in argument is not recognized by this method, then the matcher returned by this method will return true.
      Specified by:
      deriveDirectoryMatcher in interface PathMatcherFactory
      Parameters:
      fileMatcher - a matcher created by one of the other methods of this interface
      Returns:
      filter for directories that may contain the selected files
    • includesAll

      @Nonnull public PathMatcher includesAll()
      Description copied from interface: PathMatcherFactory
      Returns the path matcher that unconditionally returns true for all files. It should be the matcher returned by the other methods of this interface when the given patterns match all files.
      Specified by:
      includesAll in interface PathMatcherFactory
      Returns:
      path matcher that unconditionally returns true for all files