diff --git a/src/etc/testcases/taskdefs/unzip.xml b/src/etc/testcases/taskdefs/unzip.xml
index 61e42c92c..824cf55a8 100644
--- a/src/etc/testcases/taskdefs/unzip.xml
+++ b/src/etc/testcases/taskdefs/unzip.xml
@@ -4,6 +4,9 @@
+
+
+
@@ -28,4 +31,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java
index 1e2286fc1..523708918 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Expand.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java
@@ -182,17 +182,25 @@ public class Expand extends Task {
String name = entryName;
boolean included = false;
for (int v = 0; v < patternsets.size(); v++) {
- included = true;
PatternSet p = (PatternSet) patternsets.elementAt(v);
String[] incls = p.getIncludePatterns(getProject());
- if (incls != null) {
- for (int w = 0; w < incls.length; w++) {
- included = DirectoryScanner.match(incls[w], name);
- if (included) {
- break;
- }
+ if (incls == null || incls.length == 0) {
+ // no include pattern implicitly means includes="**"
+ incls = new String[] {"**"};
+ }
+
+ for (int w = 0; w < incls.length; w++) {
+ included = DirectoryScanner.match(incls[w], name);
+ if (included) {
+ break;
}
}
+
+ if (!included) {
+ break;
+ }
+
+
String[] excls = p.getExcludePatterns(getProject());
if (excls != null) {
for (int w = 0; w < excls.length; w++) {
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java
index aedaa19c3..cc276ff49 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2001,2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -101,4 +101,37 @@ public class UnzipTest extends BuildFileTest {
project.resolveFile("asf-logo.gif")));
}
+ /*
+ * PR 11100
+ */
+ public void testPatternSetExcludeOnly() {
+ executeTarget("testPatternSetExcludeOnly");
+ assertTrue("1/foo is excluded",
+ !getProject().resolveFile("unziptestout/1/foo").exists());
+ assertTrue("2/bar is not excluded",
+ getProject().resolveFile("unziptestout/2/bar").exists());
+ }
+
+ /*
+ * PR 11100
+ */
+ public void testPatternSetIncludeOnly() {
+ executeTarget("testPatternSetIncludeOnly");
+ assertTrue("1/foo is not included",
+ !getProject().resolveFile("unziptestout/1/foo").exists());
+ assertTrue("2/bar is included",
+ getProject().resolveFile("unziptestout/2/bar").exists());
+ }
+
+ /*
+ * PR 11100
+ */
+ public void testPatternSetIncludeAndExclude() {
+ executeTarget("testPatternSetIncludeAndExclude");
+ assertTrue("1/foo is not included",
+ !getProject().resolveFile("unziptestout/1/foo").exists());
+ assertTrue("2/bar is excluded",
+ !getProject().resolveFile("unziptestout/2/bar").exists());
+ }
+
}