About File Pattern Matching

Patterns can be used for the inclusion and exclusion of files. For example:

Patterns are considered in terms of relative paths, relative to a base directory. So a pattern like ../foo.java will not match anything when applied since the base directory's parent is never included.

NOTE  When you assign a project or stream to an area, you specify a folder offset for the location of the files for that project/stream. Any file matching pattern will need to take account of the fact that different projects/streams are likely to have different folder offsets relative to the base directory for the area.


Combinations of * and ? are allowed.

Matching is done per-directory. 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.

It is also 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, ** is used as the name of a directory. When ** is used, it matches zero or more directories. For example,
test/** matches all files and directories under /test/, such as /test/x.java, or /test/foo/bar/xyz.html, but not /xyz.xml.

There is one other convention. if a pattern ends with / or \, then ** is assumed to be appended. For example, mypackage/test/ is interpreted as if it were mypackage/test/**.

Further examples:





But not:





But not: