From cd3082d035a106f627380d5b0643b00b1c6f28f4 Mon Sep 17 00:00:00 2001 From: Bruce Atherton Date: Tue, 4 Feb 2003 17:29:11 +0000 Subject: [PATCH] Added references to Selectors in fileset documentation, and cleaned up directory task documentation to be more accurate as well as point to selectors. PR: 16682 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273977 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTypes/fileset.html | 26 ++++- docs/manual/dirtasks.html | 158 +++++++++++++++++++++++------ 2 files changed, 152 insertions(+), 32 deletions(-) diff --git a/docs/manual/CoreTypes/fileset.html b/docs/manual/CoreTypes/fileset.html index 760ebe4f5..1e0f0951e 100644 --- a/docs/manual/CoreTypes/fileset.html +++ b/docs/manual/CoreTypes/fileset.html @@ -11,7 +11,8 @@

FileSets are groups of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets. FileSets can appear inside tasks +href="patternset.html">PatternSets and +Selectors. FileSets can appear inside tasks that support this feature or at the same level as target - i.e., as children of project.

PatternSets can be specified as nested @@ -21,6 +22,10 @@ an implicit PatternSet and supports the nested <exclude> and <excludesfile> elements of PatternSet directly, as well as PatternSet's attributes.

+

Selectors are available as nested elements.within the FileSet. +If any of the selectors within the FileSet do not select the file, the +file is not considered part of the FileSet. This makes FileSets +euqivalent to an <and> selector container.

@@ -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 @@

Directory-based Tasks

-

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:

-

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 +

Patternset

+ +

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:

+ +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.

-

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).

+ +

Patterns

+ +

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

Attribute
- + org/apache/CVS/foo/bar/Entries (foo/bar/ + part does not match) -
**/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/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

+

Selectors

+

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.

+ +

Standard Tasks/Filesets

+

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:

+ + +

Examples

 <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.

Default Excludes

-

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.