Attribute |
@@ -110,6 +115,25 @@ a PatternSet that can be referenced in other
Groups all files in directory ${client.src}
, using the
same patterns as the above example.
+
+<fileset dir="${server.src}" casesensitive="yes">
+ <filename name="**/*.java"/>
+ <filename name="**/*Test*" negate="true"/>
+</fileset>
+
+Groups the same files as the top example, but using the
+<filename>
selector.
+
+<fileset dir="${server.src}" casesensitive="yes">
+ <filename name="**/*.java"/>
+ <not>
+ <filename name="**/*Test*"/>
+ </not>
+</fileset>
+
+Groups the same files as the previous example using a combination of the
+<filename>
selector and the <not>
+selector container.
Copyright © 2000-2002 Apache Software Foundation.
diff --git a/docs/manual/dirtasks.html b/docs/manual/dirtasks.html
index 795586e26..997f311db 100644
--- a/docs/manual/dirtasks.html
+++ b/docs/manual/dirtasks.html
@@ -8,29 +8,62 @@
-Some tasks use directory trees for the task they perform.
-For example, the javac task, which works upon a directory tree
-with .java
files.
-Sometimes it can be very useful to work on a subset of that directory tree. This
-section describes how you can select a subset of such a directory tree.
-Ant gives you two ways to create a subset, both of which can be used at the same
-time:
+Some tasks use directory trees for the actions they perform.
+For example, the javac task, which
+compiles a directory tree with .java
files into
+.class
files, is one of these directory-based tasks. Because
+some of these tasks do so much work with a directory tree, the task itself
+can act as an implicit FileSet.
+Whether the fileset is implicit or not, it can often be very useful to
+work on a subset of the directory tree. This section describes how you can
+select a subset of such a directory tree when using one of these
+directory-based tasks.
+Ant gives you two ways to create a subset of files in a fileset, both of
+which can be used at the same time:
- - Only include files/directories that match at least one pattern of a set of
- patterns.
- - Exclude files/directories that match at least one pattern a set of
- patterns.
+ - Only include files and directories that match any
+
include
patterns and do not match any
+ exclude
patterns in a given
+ PatternSet.
+ - Select files based on selection criteria defined by a collection of
+ selector nested elements.
-When both inclusion and exclusion are used, only files/directories that match
-the include patterns, and don't match the exclude patterns, are used.
-Patterns can be specified inside the buildfile via task attributes or
-nested elements and via external files. Each line of the external file
+
+
+We said that Directory-based tasks can sometimes act as an implicit
+<fileset>
,
+but in addtion to that, a FileSet acts as an implicit
+<patternset>
.
+
+The inclusion and exclusion elements of the implicit PatternSet can be
+specified inside the directory-based task (or explicit fileset) via
+either:
+
+ - the attributes
includes
and
+ excludes
.
+ - nested elements
<include>
and
+ <exclude>
.
+ - external files specified with the attributes
+
includesfile
and excludesfile
.
+ - external files specified with the nested elements
+
<includesfile>
and <excludesfile>
.
+
+
+When dealing with an external file, each line of the file
is taken as a pattern that is added to the list of include or exclude
patterns.
-
-As described earlier, patterns are used for the inclusion and exclusion.
-These patterns look very much like the patterns used in DOS and UNIX:
+
+When both inclusion and exclusion are used, only files/directories that
+match at least one of the include patterns and don't match any of the
+exclude patterns are used. If no include pattern is given, all files
+are assumed to match the include pattern (with the possible exception of
+the default excludes).
+
+
+
+As described earlier, patterns are used for the inclusion and exclusion
+of files. These patterns look very much like the patterns used in DOS and
+UNIX:
'*' matches zero or more characters, '?' matches one character.
Examples:
@@ -45,7 +78,8 @@ not FooBar.xml
(does not end with .java
).
Combinations of *
's and ?
's are allowed.
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
+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
,
@@ -72,7 +106,8 @@ For example, mypackage/test/
is interpreted as if it were
**/CVS/* |
- Matches all files in CVS directories that can be located
+ | Matches all files in CVS
+ directories that can be located
anywhere in the directory tree.
Matches:
@@ -82,12 +117,14 @@ For example, mypackage/test/ is interpreted as if it were
But not:
- org/apache/CVS/foo/bar/Entries (foo/bar/ part does not match) |
+ org/apache/CVS/foo/bar/Entries (foo/bar/
+ part does not match)
org/apache/jakarta/** |
- Matches all files in the org/apache/jakarta directory tree.
+ | Matches all files in the org/apache/jakarta
+ directory tree.
Matches:
org/apache/jakarta/tools/ant/docs/index.html
@@ -124,7 +161,57 @@ For example, mypackage/test/ is interpreted as if it were
When these patterns are used in inclusion and exclusion, you have a powerful
way to select just the files you want.
-Examples
+
+The <fileset> ,
+whether implicit or explicit in the
+directory-based task, also acts as an
+<and>
+selector container. This can be used to create arbitrarily complicated
+selection criteria for the files the task should work with. See the
+Selector documentation for more
+information.
+
+
+Many of the standard tasks in ant take one or more filesets which follow
+the rules given here. This list, a subset of those, is a list of standard ant
+tasks that can act as an implicit fileset:
+
+
+
<copy todir="${dist}">
<fileset dir="${src}"
@@ -136,7 +223,6 @@ way to select just the files you want.
located in the directory tree defined by ${src} to the
destination directory defined by ${dist} ,
but excludes all *.gif files from the copy.
- This example can also be expressed using nested elements:
<copy todir="${dist}">
<fileset dir="${src}">
@@ -145,10 +231,20 @@ but excludes all *.gif files from the copy.
</fileset>
</copy>
+ The same as the example above, but expressed using nested elements.
+
+
+<delete dir="${dist}">
+ <include name="**/images/*"/>
+ <exclude name="**/*.gif"/>
+</delete>
+
+Deleting the original set of files, the delete task can act
+as an implicit fileset.
-There are a set of definitions that are excluded by default from all directory-based tasks.
-They are:
+There are a set of definitions that are excluded by default from all
+directory-based tasks. They are:
**/*~
**/#*#
@@ -165,11 +261,11 @@ They are:
**/.svn/**
**/.DS_Store
-If you do not want these default excludes applied, you may disable them with the
-defaultexcludes="no" attribute.
+If you do not want these default excludes applied, you may disable them
+with the defaultexcludes="no" attribute.
-Copyright © 2000-2003 Apache Software Foundation. All rights
-Reserved.
+Copyright © 2000-2003 Apache Software Foundation. All
+rights Reserved.
|