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=21941>.
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=21941

Filesets with directories excluded still scan the directories

           Summary: Filesets with directories excluded still scan the
                    directories
           Product: Ant
           Version: 1.5.3
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Overview Description:
This came up as a problem for me when I was developing a test suite, and wanted 
to have the test data in a sub-package of my source files for the tests.  There 
were a LOT of test files, and it tripled the build time for the project, having 
them located there.  I tried adding an exclude for the test data directory, but 
it did not prevent the scanning of the directory.

Steps to reproduce:
1) Create a directory (the basedir) with a "src" sub-directory.
2) Place the build file below in the basedir you created.
3) Place the java file below in the "src" directory.
4) Run ant from the basedir with the "build" target.
5) Run ant again from the basedir, comparing the speeds of the "test_slow" 
and "test_fast" targets.  If the time difference isn't large enough, just 
increase the number of files in the "testdir" directory.

File: TestProg.java
import java.io.File;

public class TestProg {
        private static final File testDir = new File("src/testdir");
        
        public static void main(String[] args) throws Exception {
                testDir.mkdirs();
                for(int i=0; i<20000; i++) {
                        File testFile = new File(testDir, "test" + 
Integer.toString(i) + ".txt");
                        testFile.createNewFile();
                }
        }
}

File: build.xml
<?xml version="1.0"?>
<project name="exclude_bug" basedir="." default="build">
  <description>
    Demonstrates a bug with fileset "exclude" support which can cause
    (among other things) javac tasks to take WAY too long when there
    are a lot of files excluded.
  </description>

  <target name="build" description="Generates a bunch of files in src/testdir">
    <mkdir dir="${basedir}/dest"/>
    <javac srcdir="${basedir}/src" destdir="${basedir}/dest"/>
    <java classname="TestProg" classpath="${basedir}/dest"/>
  </target>

  <target name="test_slow" description="Demonstrates that the excluded 
directory is still scanned.">
    <javac srcdir="${basedir}/src" destdir="${basedir}/dest">
      <exclude name="{$basedir}/src/testdir"/>
    </javac>
  </target>
  
  <target name="test_fast" description="Shows how quickly the build can be if 
excluded directories are not scanned.">
    <javac srcdir="${basedir}/src" destdir="${basedir}/dest">
      <include name="*.java"/>
    </javac>
  </target>
</project>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to