diff --git a/docs/index.html b/docs/index.html index 8bd0e04a2..21f80611b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -375,6 +375,10 @@ 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 +is taken as 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:

@@ -617,9 +621,9 @@ UNIX system.

Description

Copies a directory tree from the source to the destination.

It is possible to refine the set of files that are being copied. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on excludes attribute.

included. All files are included when omitted. No + + includesfile + the name of a file. Each line of this file is + taken to be an include pattern + No + excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No + + excludesfile + the name of a file. Each line of this file is + taken to be an exclude pattern + No + defaultexcludes indicates whether default excludes should be used or not @@ -806,9 +822,9 @@ repository pointed to by the cvsRoot attribute, and stores the files in "${

Deletes either a single file or all files in a specified directory and its sub-directories.

It is possible to refine the set of files that are being deleted. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included in the deletion process by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included in the deletion process by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded from the deletion process. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on dir directory.

and any sub-directories are deleted when omitted. No + + includesfile + the name of a file. Each line of this file is + taken to be an include pattern + No + excludes Comma separated list of patterns of files that must be excluded from the deletion list. No files (except default excludes) are excluded when omitted. No + + excludesfile + the name of a file. Each line of this file is + taken to be an exclude pattern + No + defaultexcludes Indicates whether default excludes should be used or not @@ -1012,7 +1040,16 @@ with 2000.

FixCRLF

Description

Adjusts a text file to local.

-

The basedir attribute is the reference directory from where to jar.

+

It is possible to refine the set of files that are being adjusted. This can be +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify +the files you want to have excluded. This is also done with patterns. And +finally with the defaultexcludes attribute, you can specify whether you +want to use default exclusions or not. See the section on directory based tasks, on how the +inclusion/exclusion of files works, and how to write patterns. The patterns are +relative to the src directory.

Parameters

@@ -1037,12 +1074,24 @@ with 2000.

included. All files are included when omitted. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
No
includesfilethe name of a file. Each line of this file is + taken to be an include patternNo
excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
excludesfilethe name of a file. Each line of this file is + taken to be an exclude patternNo
defaultexcludes indicates whether default excludes should be used or not @@ -1246,9 +1295,9 @@ subdir is a directory).

Jars a set of files.

The basedir attribute is the reference directory from where to jar.

It is possible to refine the set of files that are being jarred. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on included. All files are included when omitted.

No
includesfilethe name of a file. Each line of this file is + taken to be an include patternNo
excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
excludesfilethe name of a file. Each line of this file is + taken to be an exclude patternNo
defaultexcludes indicates whether default excludes should be used or not @@ -1427,9 +1488,9 @@ classpath.

The directory structure of the source tree should follow the package hierarchy.

It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on srcdir directory.

included. All files are included when omitted.
No
includesfilethe name of a file. Each line of this file is + taken to be an include patternNo
excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
excludesfilethe name of a file. Each line of this file is + taken to be an exclude patternNo
defaultexcludes indicates whether default excludes should be used or not @@ -2165,9 +2238,9 @@ compiled files will be stored in the directory ${build}/classes.

Creates a tar archive.

The basedir attribute is the reference directory from where to tar.

It is possible to refine the set of files that are being tarred. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on included. All files are included when omitted.

No
includesfilethe name of a file. Each line of this file is + taken to be an include patternNo
excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
excludesfilethe name of a file. Each line of this file is + taken to be an exclude patternNo
defaultexcludes indicates whether default excludes should be used or not @@ -2294,9 +2379,9 @@ initialization target.

This is useful for building views of XML based documentation, or in generating code.

It is possible to refine the set of files that are being copied. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on

No
includescomma separated list of patterns of files that must be + included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is + taken to be an include patternNo
excludescomma separated list of patterns of files that must be + excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is + taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not + ("yes"/"no"). Default excludes are used when omitted.No

Examples

@@ -2385,9 +2500,9 @@ carried from tarfile.

Creates a zipfile.

The basedir attribute is the reference directory from where to zip.

It is possible to refine the set of files that are being zipped. This can be -done with the includes, excludes and defaultexcludes -attributes. With the includes attribute you specify the files you want to -have included by using patterns. The exclude attribute is used to specify +done with the includes, includesfile, excludes, excludesfile and defaultexcludes +attributes. With the includes or includesfile attribute you specify the files you want to +have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on included. All files are included when omitted. No + + includesfile + the name of a file. Each line of this file is + taken to be an include pattern + No + excludes comma separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No + + excludesfile + the name of a file. Each line of this file is + taken to be an exclude pattern + No + defaultexcludes indicates whether default excludes should be used or not @@ -2590,10 +2717,10 @@ specific directory via parameters

The directory structure of the source tree should follow the package hierarchy.

It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, excludes and -defaultexcludes attributes. With the includes attribute you +This can be done with the includes, includesfile, excludes, excludesfile and +defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The -exclude attribute is used to specify the files you want to have +exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on srcDir directory.

omitted. No + + excludesfile + the name of a file. Each line of this file is + taken to be an exclude pattern + No + explicit Whether variables must be declared explicitly @@ -2698,6 +2831,12 @@ patterns are relative to the srcDir directory.

included. All files are included when omitted. No + + includesfile + the name of a file. Each line of this file is + taken to be an include pattern + No + java Whether the generated java code is produced @@ -2854,6 +2993,12 @@ patterns are relative to the srcDir directory.

omitted. No + + excludesfile + the name of a file. Each line of this file is + taken to be an exclude pattern + No + fromExtention The string that files must end in to be renamed @@ -2865,6 +3010,12 @@ patterns are relative to the srcDir directory.

included. All files are included when omitted. No + + includesfile + the name of a file. Each line of this file is + taken to be an include pattern + No + replace Whether the file being renamed to should be diff --git a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java index 35056da24..0be2f7261 100644 --- a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java @@ -107,18 +107,14 @@ public abstract class MatchingTask extends Task { * add a name entry on the include list */ public NameEntry createInclude() { - NameEntry result = new NameEntry(); - includeList.addElement(result); - return result; + return addPatternToList(includeList); } /** * add a name entry on the exclude list */ public NameEntry createExclude() { - NameEntry result = new NameEntry(); - excludeList.addElement(result); - return result; + return addPatternToList(excludeList); } /** @@ -239,4 +235,76 @@ public abstract class MatchingTask extends Task { ds.scan(); return ds; } + + /** + * add a name entry to the given list + */ + private NameEntry addPatternToList(Vector list) { + NameEntry result = new NameEntry(); + list.addElement(result); + return result; + } + + /** + * Reads path matching patterns from a file and adds them to the + * includes or excludes list (as appropriate). + */ + private void readPatterns(File patternfile, Vector patternlist) { + + try { + // Get a FileReader + BufferedReader patternReader = + new BufferedReader(new FileReader(patternfile)); + + // Create one NameEntry in the appropriate pattern list for each + // line in the file. + String line = patternReader.readLine(); + while (line != null) { + if (line.length() > 0) { + addPatternToList(patternlist).setName(line); + } + line = patternReader.readLine(); + } + } catch(IOException ioe) { + project.log("An error occured while reading from pattern file: " + + patternfile, Project.MSG_ERR); + } + } + + /** + * Sets the name of the file containing the includes patterns. + * + * @param includesfile A string containing the filename to fetch + * the include patterns from. + */ + public void setIncludesfile(String includesfile) { + if (includesfile != null && includesfile.length() > 0) { + File incl = project.resolveFile(includesfile); + if (!incl.exists()) { + project.log("Includesfile "+includesfile+" not found.", + Project.MSG_ERR); + } else { + readPatterns(incl, includeList); + } + } + } + + /** + * Sets the name of the file containing the includes patterns. + * + * @param excludesfile A string containing the filename to fetch + * the include patterns from. + */ + public void setExcludesfile(String excludesfile) { + if (excludesfile != null && excludesfile.length() > 0) { + File excl = project.resolveFile(excludesfile); + if (!excl.exists()) { + project.log("Excludesfile "+excludesfile+" not found.", + Project.MSG_ERR); + } else { + readPatterns(excl, excludeList); + } + } + } + }