git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@468781 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -13,6 +13,9 @@ Fixed bugs: | |||||
| * <delete> doesnt delete when defaultexcludes="false" and no includes is set | * <delete> doesnt delete when defaultexcludes="false" and no includes is set | ||||
| fixed. Bugzilla 40313. | fixed. Bugzilla 40313. | ||||
| * behavior change of DirectoryScanner/AbstractFileset when conditional include | |||||
| patterns are used. Bugzilla 40722. | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -459,12 +459,16 @@ public abstract class AbstractFileSet extends DataType | |||||
| } | } | ||||
| ds.setBasedir(dir); | 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 | 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) { | if (ds instanceof SelectorScanner) { | ||||
| SelectorScanner ss = (SelectorScanner) ds; | SelectorScanner ss = (SelectorScanner) ds; | ||||
| ss.setSelectors(getSelectors(p)); | ss.setSelectors(getSelectors(p)); | ||||
| @@ -117,11 +117,12 @@ public class PatternSet extends DataType implements Cloneable { | |||||
| * @return a printable form of this object. | * @return a printable form of this object. | ||||
| */ | */ | ||||
| public String toString() { | public String toString() { | ||||
| StringBuffer buf = new StringBuffer(); | |||||
| if (name == null) { | 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)) { | if ((ifCond != null) || (unlessCond != null)) { | ||||
| buf.append(":"); | buf.append(":"); | ||||
| String connector = ""; | String connector = ""; | ||||
| @@ -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> | |||||