Package org.apache.maven.impl
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateExcludeOnlyMatcher(Path baseDirectory, Collection<String> excludes, boolean useDefaultExcludes) Creates a path matcher that includes all files except those matching the exclude patterns.createPathMatcher(Path baseDirectory, Collection<String> includes, Collection<String> excludes, boolean useDefaultExcludes) Creates a path matcher for filtering files based on include and exclude patterns.deriveDirectoryMatcher(PathMatcher fileMatcher) Returns a filter for directories that may contain paths accepted by the given matcher.Returns the path matcher that unconditionally returnstruefor all files.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.api.services.PathMatcherFactory
createIncludeOnlyMatcher, createPathMatcher, isIncludesAll
-
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:PathMatcherFactoryCreates 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:
createPathMatcherin interfacePathMatcherFactory- Parameters:
baseDirectory- the base directory for relativizing paths during matchingincludes- the patterns of files to include, or null/empty for including all filesexcludes- the patterns of files to exclude, or null/empty for no exclusionuseDefaultExcludes- 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:PathMatcherFactoryCreates a path matcher that includes all files except those matching the exclude patterns.This is equivalent to calling
PathMatcherFactory.createPathMatcher(Path, Collection, Collection, boolean)withincludes = null.- Specified by:
createExcludeOnlyMatcherin interfacePathMatcherFactory- Parameters:
baseDirectory- the base directory for relativizing paths during matchingexcludes- the patterns of files to exclude, or null/empty for no exclusionuseDefaultExcludes- whether to augment excludes with default SCM exclusion patterns- Returns:
- a PathMatcher that can be used to test if paths should be included
-
deriveDirectoryMatcher
Description copied from interface:PathMatcherFactoryReturns 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 returnsfalse, 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 returntrue.- Specified by:
deriveDirectoryMatcherin interfacePathMatcherFactory- 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
Description copied from interface:PathMatcherFactoryReturns the path matcher that unconditionally returnstruefor all files. It should be the matcher returned by the other methods of this interface when the given patterns match all files.- Specified by:
includesAllin interfacePathMatcherFactory- Returns:
- path matcher that unconditionally returns
truefor all files
-