* matches only the first sub-directory and its content, plus the files of the current dir, no other directories
** matches all sub-directoryes and their content
for example, c:\path\to\something\** will match everything under \something
to include the current dir for file search, start pattern path with **
Matching is done per-directory. This means that first the first directory in the pattern is matched against the first directory in the path to match. Then the second directory is matched, and so on. For example, when we have the pattern
/?abc/*/*.java
and the path /xabc/foobar/test.java
,
the first ?abc
is matched with xabc
,
then *
is matched with foobar
,
and finally *.java
is matched with test.java
.
They all match, so the path matches the pattern.To make things a bit more flexible, we add one extra feature, which makes it possible to match multiple directory levels. This can be used to match a complete directory tree, or a file anywhere in the directory tree. To do this,
**
must be used as the name of a directory.
When **
is used as the name of a
directory in the pattern, it matches zero or more directories.
For example:
/test/**
matches all files/directories under /test/
,
such as /test/x.java
,
or /test/foo/bar/xyz.html
, but not /xyz.xml
.There is one "shorthand": if a pattern ends with
/
or \
, then **
is appended.
For example, mypackage/test/
is interpreted as if it were
mypackage/test/**
.Example patterns:
**/CVS/* |
Matches all files in CVS
directories that can be located
anywhere in the directory tree.Matches: CVS/Repository org/apache/CVS/Entries org/apache/jakarta/tools/ant/CVS/EntriesBut not: org/apache/CVS/foo/bar/Entries (
|
org/apache/jakarta/** |
Matches all files in the org/apache/jakarta
directory tree.Matches: org/apache/jakarta/tools/ant/docs/index.html org/apache/jakarta/test.xmlBut not: org/apache/xyz.java( jakarta/ part is missing). |
org/apache/**/CVS/* |
Matches all files in CVS directories
that are located anywhere in the directory tree under
org/apache .Matches: org/apache/CVS/Entries org/apache/jakarta/tools/ant/CVS/EntriesBut not: org/apache/CVS/foo/bar/Entries( foo/bar/ part does not match) |
**/test/** |
Matches all files that have a test
element in their path, including test as a filename. |
No comments:
Post a Comment