From f1bc629e34874c4d641b159e31a55ed2cab6ca20 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig since Ant 1.6 Alters the default excludes for all subsequent processing in the
+build, and prints out the current default excludes if desired.
+
+ Print out the default excludes Print out the default excludes and exclude all *.bak files in
+all further processing Silently allow several fileset based tasks to operate on emacs
+backup files and then restore normal behavior Copyright © 2003 Apache Software Foundation. All rights
+Reserved.DefaultExcludes
+
+Description
+Parameters
+
+
+
+
+
+ Attribute
+ Description
+ Required
+
+
+ echo
+ whether or not to print out the default excludes.(defaults to false)
+ atribute "true" required if no
+ other argument specified
+
+
+ add
+ the pattern to add to the default excludes
+ if no other atribute is specified
+
+
+remove
+ remove the specified pattern from the default excludes
+ if no other atribute is specified
+ Examples
+
+ <defaultexcludes echo="true"/>
+
+ <defaultexcludes echo="true" add="**/*.bak"/>
+
+
+ <defaultexcludes remove="**/*~"/>
+
+ (do several fileset based tasks here)
+
+ <defaultexcludes add="**/*~"/>
+
+
+
+
+
+
CVSPass
CvsTagDiff
+Defaultexcludes
Delete
Deltree
Dependset
diff --git a/docs/manual/dirtasks.html b/docs/manual/dirtasks.html
index 997f311db..b73e1c2aa 100644
--- a/docs/manual/dirtasks.html
+++ b/docs/manual/dirtasks.html
@@ -261,8 +261,14 @@ directory-based tasks. They are:
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.
This is the default list, note that you can modify the list of +default excludes by using the defaultexcludes task.
+Copyright © 2000-2003 Apache Software Foundation. All rights Reserved.
diff --git a/src/etc/testcases/taskdefs/defaultexcludes.xml b/src/etc/testcases/taskdefs/defaultexcludes.xml new file mode 100644 index 000000000..cf608e851 --- /dev/null +++ b/src/etc/testcases/taskdefs/defaultexcludes.xml @@ -0,0 +1,19 @@ + + +String
based on the current
+ * contents of the defaultExcludes
+ * Vector
.
+ */
+ public static String[] getDefaultExcludes() {
+ return (String[]) defaultExcludes.toArray(new String[defaultExcludes.size()]);
+ }
+
+ /**
+ * Add a pattern to the default excludes unless it is already a
+ * default exclude.
+ *
+ * @param s A string to add as an exclude pattern.
+ * @return true
if the string was added
+ * false
if it already
+ * existed.
+ */
+ public static boolean addDefaultExclude(String s){
+ if (defaultExcludes.indexOf(s) == -1) {
+ defaultExcludes.add(s);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Remove a string if it is a default exclude.
+ *
+ * @param s The string to attempt to remove.
+ * @return true
if s
was a default
+ * exclude (and thus was removed),
+ * false
if s
was not
+ * in the default excludes list to begin with
+ */
+ public static boolean removeDefaultExclude(String s) {
+ return defaultExcludes.remove(s);
+ }
+
/**
* Sets the base directory to be scanned. This is the directory which is
* scanned recursively. All '/' and '\' characters are replaced by
@@ -938,13 +976,15 @@ public class DirectoryScanner
public void addDefaultExcludes() {
int excludesLength = excludes == null ? 0 : excludes.length;
String[] newExcludes;
- newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length];
+ newExcludes = new String[excludesLength + defaultExcludes.size()];
if (excludesLength > 0) {
System.arraycopy(excludes, 0, newExcludes, 0, excludesLength);
}
- for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
- newExcludes[i + excludesLength] = DEFAULTEXCLUDES[i].replace('/',
- File.separatorChar).replace('\\', File.separatorChar);
+ String[] defaultExcludesTemp = getDefaultExcludes();
+ for (int i = 0; i < defaultExcludesTemp.length; i++) {
+ newExcludes[i + excludesLength] = defaultExcludesTemp[i].
+ replace('/', File.separatorChar).
+ replace('\\', File.separatorChar);
}
excludes = newExcludes;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
new file mode 100644
index 000000000..f7131d1e0
--- /dev/null
+++ b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
@@ -0,0 +1,139 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "Ant" and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ *