Class PathSelector
java.lang.Object
org.apache.maven.impl.PathSelector
- All Implemented Interfaces:
PathMatcher
Determines whether a path is selected according to include/exclude patterns.
The pathnames used for method parameters will be relative to some base directory
and use
'/' as separator, regardless of the hosting operating system.
Syntax
If a pattern contains the':' character and the prefix before is longer than 1 character,
then that pattern is given verbatim to FileSystem.getPathMatcher(String), which interprets
the part before ':' as the syntax (usually "glob" or "regex").
If a pattern does not contain the ':' character, or if the prefix is one character long
(interpreted as a Windows drive), then the syntax defaults to a reproduction of the Maven 3 behavior.
This is implemented as the "glob" syntax with the following modifications:
- The platform-specific separator (
'\\'on Windows) is replaced by'/'. Note that it means that the backslash cannot be used for escaping characters. - Trailing
"/"is completed as"/**". - The
"**"wildcard means "0 or more directories" instead of "1 or more directories". This is implemented by adding variants of the pattern without the"**"wildcard. - Bracket characters [ ] and { } are escaped.
- On Unix only, the escape character
'\\'is itself escaped.
"glob:" prefix before the pattern.
Note that putting such a prefix is recommended anyway for better performances.- Author:
- Benjamin Bentmann, Martin Desruisseaux
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPathSelector(Path directory, Collection<String> includes, Collection<String> excludes, boolean useDefaultExcludes) Creates a new selector from the given includes and excludes. -
Method Summary
Modifier and TypeMethodDescriptionbooleancouldHoldSelected(Path directory) Determines whether a directory could contain selected paths.booleanDetermines whether a path is selected.simplify()Returns a potentially simpler matcher equivalent to this matcher.toString()Returns a string representation for logging purposes.
-
Constructor Details
-
PathSelector
public PathSelector(Path directory, Collection<String> includes, Collection<String> excludes, boolean useDefaultExcludes) Creates a new selector from the given includes and excludes.- Parameters:
directory- the base directory of the files to filterincludes- the patterns of the files to include, or null or empty for including all filesexcludes- the patterns of the files to exclude, or null or empty for no exclusionuseDefaultExcludes- whether to augment the excludes with a default set of SCM patterns
-
-
Method Details
-
simplify
Returns a potentially simpler matcher equivalent to this matcher..- Returns:
- a potentially simpler matcher equivalent to this matcher
-
matches
Determines whether a path is selected. This is true if the given file matches an include pattern and no exclude pattern.- Specified by:
matchesin interfacePathMatcher- Parameters:
path- the pathname to test, must not benull- Returns:
trueif the given path is selected,falseotherwise
-
couldHoldSelected
Determines whether a directory could contain selected paths.- Parameters:
directory- the directory pathname to test, must not benull- Returns:
trueif the given directory might contain selected paths,falseif the directory will definitively not contain selected paths
-
toString
-