DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12838>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12838 DirectoryScanner ignores includes/excludes/selectors on referenced filesets Summary: DirectoryScanner ignores includes/excludes/selectors on referenced filesets Product: Ant Version: 1.5 Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Core AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] To get right to the point... setupDirectoryScanner(FileScanner ds, Project p) in AbstractFileSet.java does not dereference referenced file sets. If you set up a scanner against a fileset that is referenced (refid=xxx), the scanner is actually set against the "pointer" fileset which has no include or exclude patterns. This means the scanner will scan everything. In my case I was using referenced file sets within an FTP-delete command, and every file in and below the CWD was being deleted -- rather than just the few files I asked for. :-( For example, suppose we have this build.xml file: <?xml version="1.0"?> <project default="test"> <target name="test"> <fileset dir="/tmp" id="myset"> <include name="foo"/> </fileset> <ftp action="list" server="${ftp.server}" userid="${ftp.userid}" password="${ftp.password}" remotedir="/tmp" verbose="yes" listing="xxx.txt" > <fileset refid="myset"/> </ftp> </target> </project> This build should list "/tmp/foo" on the ftp server. But with the bug, because the nested fileset is a reference, the <ftp> task instead lists the entire contents of the /tmp directory, recursively. In the debugging message below, you can see that the pattern set is empty. It does not contain a name restriction. test2: Adding reference: myset -> [EMAIL PROTECTED] [ftp] Opening FTP connection to xxx.xxx.xxx.xxx [ftp] connected [ftp] logging in to FTP server [ftp] login succeeded [ftp] changing the remote directory [ftp] listing files fileset: Setup scanner in dir null with patternSet{ includes: [] excludes: [] } [ftp] listing .X0-lock [ftp] listing .X11-unix\X0 [ftp] listing .font-unix\fs7100 [ftp] listing bar [ftp] listing foo [ftp] 5 files listed [ftp] disconnecting I fixed the bug on my system so that "myset" is properly deferenced. Now the pattern set is found and <ftp> does the right thing: test2: Adding reference: myset -> [EMAIL PROTECTED] [ftp] Opening FTP connection to xxx.xxx.xxx.xxx [ftp] connected [ftp] logging in to FTP server [ftp] login succeeded [ftp] changing the remote directory [ftp] listing files fileset: Setup scanner in dir \tmp with patternSet{ includes: [foo] excludes: [] } [ftp] listing foo [ftp] 1 files listed [ftp] disconnecting Proposed Fix: In AbstractFileSet.java, wrap the setupDirectoryScanner method logic within an if-then-else block. Recurse over references. public void setupDirectoryScanner(FileScanner ds, Project p) { if (ds == null) { throw new IllegalArgumentException("ds cannot be null"); } // *** This if-statement is new *** if (isReference()) { getRef(p).setupDirectoryScanner(ds, p); } else { ds.setBasedir(dir); 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 " + defaultPatterns, Project.MSG_DEBUG); ds.setIncludes(defaultPatterns.getIncludePatterns(p)); ds.setExcludes(defaultPatterns.getExcludePatterns(p)); if (ds instanceof SelectorScanner) { SelectorScanner ss = (SelectorScanner)ds; ss.setSelectors(getSelectors(p)); } if (useDefaultExcludes) { ds.addDefaultExcludes(); } ds.setCaseSensitive(isCaseSensitive); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
