http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1415
*** shadow/1415 Thu Apr 19 15:37:11 2001
--- shadow/1415.tmp.3480 Thu Apr 19 15:37:11 2001
***************
*** 0 ****
--- 1,98 ----
+ +============================================================================+
+ | getIncludeDirectories() in DirectoryScanner does not work the same as in v |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1415 Product: Ant |
+ | Status: NEW Version: 1.2 |
+ | Resolution: Platform: All |
+ | Severity: Normal OS/Version: All |
+ | Priority: Low Component: Core |
+ +----------------------------------------------------------------------------+
+ | Assigned To: [EMAIL PROTECTED] |
+ | Reported By: [EMAIL PROTECTED] |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ BUG:
+ When scanning for child directories where the parent directory is excluded,
+ DirectoryScanner does not return child directories (versions 1.2 and 1.3).
+ This used to work in version 1.1.
+ Furthermore, if one calls getExcludedDirectories() or any of the methods
+ that calls slowScan(), a protected method, then getIncludeDirectories()
+ returns the child directories, so getIncludeDirectories() (versions 1.2 and
1.3)
+ has two possible different results/behaviors.
+
+ SUGGESTION:
+ 1) Replace scan()(fast scan) with slowScan(), and only have one type of scan,
+ or
+ 2) add method that explicitly sets type of scan (fast or slow),
+ or
+ 3) make slowScan() a public method, so user can choose which scan to run.
+ Just remember that if 2) or 3) is implemented, you should add a setter in
+ MatchingTask to choose what type of scan() to run, and that
+ it should default to slow scan to be backwards compatible with version 1.1.
+
+
+ Here is a test program I wrote illustrating the problem:
+
+ import java.io.*;
+ import org.apache.tools.ant.*;
+
+ public class TestDirectoryScanner {
+
+ public static void main (String[] args){
+
+ // setup test
+ File dir = new File ("parent");
+ dir.mkdir();
+ dir = new File ("parent/child");
+ dir.mkdir();
+ dir = new File ("other");
+ dir.mkdir();
+
+ // create directory scanner
+ DirectoryScanner scanner = new DirectoryScanner();
+ scanner.setBasedir (new File("."));
+ scanner.setExcludes (new String[]{ "parent" });
+ scanner.scan();
+
+ System.out.println ("CALLING getIncludedDirectories()...");
+ String[] dirs = scanner.getIncludedDirectories();
+ for(int i = 0; i < dirs.length; i++) {
+ System.out.println (" RETURNED DIR["+i+"]: " + dirs[i]);
+ }
+
+ scanner.getExcludedDirectories();
+
+ System.out.println ("CALLING getIncludedDirectories() AFTER CALLING
+ getExcludedDirectories()...");
+ dirs = scanner.getIncludedDirectories();
+ for(int i = 0; i < dirs.length; i++) {
+ System.out.println (" RETURNED DIR["+i+"]: " + dirs[i]);
+ }
+ }
+
+ }
+
+ Run it from an empty directory, as it creates the directories needed
+ for the test.
+
+
+ Here is the results for version 1.1:
+
+ CALLING getIncludedDirectories()...
+ RETURNED DIR[0]: other
+ RETURNED DIR[1]: parent\child
+ CALLING getIncludedDirectories() AFTER CALLING getExcludedDirectories()...
+ RETURNED DIR[0]: other
+ RETURNED DIR[1]: parent\child
+
+
+ Here is the results for versions 1.2 and 1.3:
+
+ CALLING getIncludedDirectories()...
+ RETURNED DIR[0]: other
+ CALLING getIncludedDirectories() AFTER CALLING getExcludedDirectories()...
+ RETURNED DIR[0]: other
+ RETURNED DIR[1]: parent\child