From d121889dca687fc281d6a24e90be4cf8a438d459 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 6 Apr 2007 17:09:48 +0000 Subject: [PATCH] Patternset allows nested inverted patternsets using . git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@526228 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 +++- docs/manual/CoreTypes/patternset.html | 3 +++ .../apache/tools/ant/types/PatternSet.java | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index 9e26ba70a..9d3e8f101 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -92,7 +92,9 @@ Other changes: * Add IgnoreDependenciesExecutor for weird cases when the user wants to run only the targets explicitly specified. - + +* Patternset allows nested inverted patternsets using . + Changes from Ant 1.6.5 to Ant 1.7.0 =================================== diff --git a/docs/manual/CoreTypes/patternset.html b/docs/manual/CoreTypes/patternset.html index 9cce22dea..6d92caf27 100644 --- a/docs/manual/CoreTypes/patternset.html +++ b/docs/manual/CoreTypes/patternset.html @@ -126,6 +126,9 @@ you can use to test the existance of a property.

patternset

Patternsets may be nested within one another, adding the nested patterns to the parent patternset.

+

invert

+

A nested patternset can be inverted using the <invert> +element. Since Ant 1.7.1

Examples

 <patternset id="non.test.sources">
diff --git a/src/main/org/apache/tools/ant/types/PatternSet.java b/src/main/org/apache/tools/ant/types/PatternSet.java
index 22bc93384..cce0817d4 100644
--- a/src/main/org/apache/tools/ant/types/PatternSet.java
+++ b/src/main/org/apache/tools/ant/types/PatternSet.java
@@ -143,6 +143,19 @@ public class PatternSet extends DataType implements Cloneable {
         }
     }
 
+    private class InvertedPatternSet extends PatternSet {
+        private InvertedPatternSet(PatternSet p) {
+            setProject(p.getProject());
+            addConfiguredPatternset(p);
+        }
+        public String[] getIncludePatterns(Project p) {
+            return super.getExcludePatterns(p);
+        }
+        public String[] getExcludePatterns(Project p) {
+            return super.getIncludePatterns(p);
+        }
+    }
+
     /**
      * Creates a new PatternSet instance.
      */
@@ -509,4 +522,11 @@ public class PatternSet extends DataType implements Cloneable {
         }
     }
 
+    /**
+     * Add an inverted patternset.
+     *
+     */
+    public void addConfiguredInvert(PatternSet p) {
+        addConfiguredPatternset(new InvertedPatternSet(p));
+    }
 }