Browse Source

merge multiple patternsets - PR 38973

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@398170 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 19 years ago
parent
commit
62fd696d56
3 changed files with 24 additions and 15 deletions
  1. +3
    -0
      WHATSNEW
  2. +1
    -0
      src/etc/testcases/taskdefs/unzip.xml
  3. +20
    -15
      src/main/org/apache/tools/ant/taskdefs/Expand.java

+ 3
- 0
WHATSNEW View File

@@ -211,6 +211,9 @@ Fixed bugs:
standardized improperly included objselect and objsel property accessors to
delegate to the inherited objSelect property accessor. Bugzilla report 37766.

* <unzip> and <untar< now correctly merge multiple nested patternsets.
Bugzilla Report 38973.

Other changes:
--------------
* took in bugzilla report 39320.


+ 1
- 0
src/etc/testcases/taskdefs/unzip.xml View File

@@ -87,6 +87,7 @@
<include name="2/**"/>
</patternset>
<patternset>
<exclude name="1/**"/>
<exclude name="2/**"/>
</patternset>
</unzip>


+ 20
- 15
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000-2005 The Apache Software Foundation
* Copyright 2000-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;

import org.apache.tools.ant.BuildException;
@@ -195,6 +197,8 @@ public class Expand extends Task {
String name = entryName.replace('/', File.separatorChar)
.replace('\\', File.separatorChar);
boolean included = false;
Set includePatterns = new HashSet();
Set excludePatterns = new HashSet();
for (int v = 0, size = patternsets.size(); v < size; v++) {
PatternSet p = (PatternSet) patternsets.elementAt(v);
String[] incls = p.getIncludePatterns(getProject());
@@ -209,18 +213,9 @@ public class Expand extends Task {
if (pattern.endsWith(File.separator)) {
pattern += "**";
}

included = SelectorUtils.matchPath(pattern, name);
if (included) {
break;
}
}

if (!included) {
break;
includePatterns.add(pattern);
}


String[] excls = p.getExcludePatterns(getProject());
if (excls != null) {
for (int w = 0; w < excls.length; w++) {
@@ -230,13 +225,23 @@ public class Expand extends Task {
if (pattern.endsWith(File.separator)) {
pattern += "**";
}
included = !(SelectorUtils.matchPath(pattern, name));
if (!included) {
break;
}
excludePatterns.add(pattern);
}
}
}

for (Iterator iter = includePatterns.iterator();
!included && iter.hasNext();) {
String pattern = (String) iter.next();
included = SelectorUtils.matchPath(pattern, name);
}

for (Iterator iter = excludePatterns.iterator();
included && iter.hasNext();) {
String pattern = (String) iter.next();
included = !SelectorUtils.matchPath(pattern, name);
}

if (!included) {
//Do not process this file
return;


Loading…
Cancel
Save