Browse Source

fix for Bugzilla 40722. Was identified as a directory scanning problem.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@468781 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 18 years ago
parent
commit
2201b1634b
4 changed files with 47 additions and 7 deletions
  1. +3
    -0
      WHATSNEW
  2. +8
    -4
      src/main/org/apache/tools/ant/types/AbstractFileSet.java
  3. +4
    -3
      src/main/org/apache/tools/ant/types/PatternSet.java
  4. +32
    -0
      src/tests/antunit/types/fileset-test.xml

+ 3
- 0
WHATSNEW View File

@@ -13,6 +13,9 @@ Fixed bugs:
* <delete> doesnt delete when defaultexcludes="false" and no includes is set
fixed. Bugzilla 40313.

* behavior change of DirectoryScanner/AbstractFileset when conditional include
patterns are used. Bugzilla 40722.

Other changes:
--------------



+ 8
- 4
src/main/org/apache/tools/ant/types/AbstractFileSet.java View File

@@ -459,12 +459,16 @@ public abstract class AbstractFileSet extends DataType
}
ds.setBasedir(dir);

PatternSet ps = mergePatterns(p);
final int count = additionalPatterns.size();
for (int i = 0; i < count; i++) {
Object o = additionalPatterns.elementAt(i);
defaultPatterns.append((PatternSet) o, p);
}
p.log(getDataTypeName() + ": Setup scanner in dir " + dir
+ " with " + ps, Project.MSG_DEBUG);
+ " with " + defaultPatterns, Project.MSG_DEBUG);

ds.setIncludes(ps.getIncludePatterns(p));
ds.setExcludes(ps.getExcludePatterns(p));
ds.setIncludes(defaultPatterns.getIncludePatterns(p));
ds.setExcludes(defaultPatterns.getExcludePatterns(p));
if (ds instanceof SelectorScanner) {
SelectorScanner ss = (SelectorScanner) ds;
ss.setSelectors(getSelectors(p));


+ 4
- 3
src/main/org/apache/tools/ant/types/PatternSet.java View File

@@ -117,11 +117,12 @@ public class PatternSet extends DataType implements Cloneable {
* @return a printable form of this object.
*/
public String toString() {
StringBuffer buf = new StringBuffer();
if (name == null) {
throw new BuildException(
"Missing attribute \"name\" for a pattern");
buf.append("noname");
} else {
buf.append(name);
}
StringBuffer buf = new StringBuffer(name);
if ((ifCond != null) || (unlessCond != null)) {
buf.append(":");
String connector = "";


+ 32
- 0
src/tests/antunit/types/fileset-test.xml View File

@@ -0,0 +1,32 @@
<project xmlns:au="antlib:org.apache.ant.antunit" default="all">
<target name="test-fileset-with-if">
<fileset id="this.xml" dir=".">
<include if="trigger.include" name="fileset-test.xml"/>
</fileset>
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/>
<au:assertTrue message="fileset this.xml should not contain anything but contains ${this.xml.prop}">
<not>
<isset property="this.xml.prop"/>
</not>
</au:assertTrue>
</target>
<target name="test-fileset-with-if-property-set">
<property name="trigger.include" value="true"/>
<fileset id="this.xml" dir=".">
<include if="trigger.include" name="fileset-test.xml"/>
</fileset>
<pathconvert refid="this.xml" property="this.xml.prop" pathsep="${line.separator}" setonempty="false"/>
<au:assertPropertySet name="this.xml.prop" message="fileset should contain one file"/>
<echo>${this.xml.prop}</echo>
<au:assertLogContains text="fileset-test.xml"/>
</target>
<target name="all">
<au:antunit>
<fileset dir="${basedir}" includes="fileset-test.xml"/>
<au:plainlistener/>
</au:antunit>
</target>
</project>

Loading…
Cancel
Save