git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@727993 13f79535-47bb-0310-9956-ffa450edef68master
@@ -309,6 +309,11 @@ Fixed bugs: | |||||
command failed. | command failed. | ||||
Bugzilla Report 46340. | Bugzilla Report 46340. | ||||
* DirectoryScanner's slow-scanning algorithm that is used when you | |||||
ask for excluded or not-included files and/or directories could | |||||
miss some files and directories in the presence of recursive | |||||
exclude patterns. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -1116,7 +1116,7 @@ public class DirectoryScanner | |||||
private void processSlowScan(String[] arr) { | private void processSlowScan(String[] arr) { | ||||
for (int i = 0; i < arr.length; i++) { | for (int i = 0; i < arr.length; i++) { | ||||
TokenizedPath path = new TokenizedPath(arr[i]); | TokenizedPath path = new TokenizedPath(arr[i]); | ||||
if (!couldHoldIncluded(path)) { | |||||
if (!couldHoldIncluded(path) || contentsExcluded(path)) { | |||||
scandir(new File(basedir, arr[i]), path, false); | scandir(new File(basedir, arr[i]), path, false); | ||||
} | } | ||||
} | } | ||||
@@ -57,7 +57,7 @@ | |||||
<au:assertFileDoesntExist file="${output}/b/c"/> | <au:assertFileDoesntExist file="${output}/b/c"/> | ||||
</target> | </target> | ||||
<target name="xtestPreserveEmptyOverridesDefault" depends="setUp"> | |||||
<target name="testPreserveEmptyOverridesDefault" depends="setUp"> | |||||
<sync todir="${output}"> | <sync todir="${output}"> | ||||
<fileset dir="${input}"/> | <fileset dir="${input}"/> | ||||
@@ -72,7 +72,7 @@ | |||||
<au:assertFileExists file="${output}/b/c"/> | <au:assertFileExists file="${output}/b/c"/> | ||||
</target> | </target> | ||||
<target name="xtestPreserveEmptyOverrulesIncludeEmpty" depends="setUp"> | |||||
<target name="testPreserveEmptyOverrulesIncludeEmpty" depends="setUp"> | |||||
<sync todir="${output}" includeEmptyDirs="true"> | <sync todir="${output}" includeEmptyDirs="true"> | ||||
<fileset dir="${input}"/> | <fileset dir="${input}"/> | ||||
@@ -25,9 +25,11 @@ import org.apache.tools.ant.util.SymbolicLinkUtils; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.Arrays; | |||||
import java.util.Iterator; | |||||
import java.util.List; | |||||
import java.util.Set; | import java.util.Set; | ||||
import java.util.TreeSet; | import java.util.TreeSet; | ||||
import java.util.Iterator; | |||||
/** | /** | ||||
* JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner | * JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner | ||||
@@ -532,4 +534,25 @@ public class DirectoryScannerTest extends BuildFileTest { | |||||
} | } | ||||
} | } | ||||
public void testRecursiveExcludes() throws Exception { | |||||
DirectoryScanner ds = new DirectoryScanner(); | |||||
ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); | |||||
ds.setExcludes(new String[] {"**/beta/**"}); | |||||
ds.scan(); | |||||
List dirs = Arrays.asList(ds.getExcludedDirectories()); | |||||
assertEquals(2, dirs.size()); | |||||
assertTrue("beta is excluded", | |||||
dirs.contains("alpha/beta".replace('/', File.separatorChar))); | |||||
assertTrue("gamma is excluded", | |||||
dirs.contains("alpha/beta/gamma".replace('/', | |||||
File.separatorChar))); | |||||
List files = Arrays.asList(ds.getExcludedFiles()); | |||||
assertEquals(2, files.size()); | |||||
assertTrue("beta.xml is excluded", | |||||
files.contains("alpha/beta/beta.xml" | |||||
.replace('/', File.separatorChar))); | |||||
assertTrue("gamma.xml is excluded", | |||||
files.contains("alpha/beta/gamma/gamma.xml" | |||||
.replace('/', File.separatorChar))); | |||||
} | |||||
} | } |