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

PatternSets are not properly isolated

           Summary: PatternSets are not properly isolated
           Product: Ant
           Version: 1.4.1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Core
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


If you specify multiple PatternSets within a FileSet, the patterns are mingled 
together rather than kept isolated. This results in all exclusions being 
applied to the results of all inclusions, which is incorrect behaviour.

Here is a test case that recreates the problem. It is a build.xml file. When 
you run it, it will create an "a" and "b" directory, create a set of files 
in "a", and attempt to copy them to "b". You can see that the only files that 
get copied are "always.java" and "always.class", despite what the patternsets 
define.

The solution appears to be to fix DirectoryScanner.java to accept a list of 
PatternSets rather than a list of include and exclude strings (or rather, for 
backward compatibility, to accept PatternSets as an alternative). FileSet.java 
should then pass the patterns into the scanner in setupDirectoryScanner().

If people agree that this is the way to go, let me know and I will write up a 
patch for it.

I'm including the build.xml file both inline here and as an attachment, for 
ease of access.

* build.xml

<project name="test-overlapping-patterns" default="test" basedir="./" >

  <target name="test" depends="create-test-env" description="Shows overlapping 
pattern problem" >
    <copy todir="b">
      <fileset dir="a">
        <patternset>
          <include name="*.java" />
          <exclude name="test*" />
        </patternset>
        <patternset>
          <include name="*.class" />
          <exclude name="old*" />
        </patternset>
      </fileset>
    </copy>
  </target>

  <target name="create-test-env">
    <delete dir="a" />
    <delete dir="b" />
    <mkdir dir="a" />
    <mkdir dir="b" />
    <touch file="a/testthis.java" />
    <touch file="a/testthis.class" />
    <touch file="a/testthat.java" />
    <touch file="a/testthat.class" />
    <touch file="a/oldthis.java" />
    <touch file="a/oldthis.class" />
    <touch file="a/oldthat.java" />
    <touch file="a/oldthat.class" />
    <touch file="a/always.java" />
    <touch file="a/always.class" />
  </target>

</project>

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

Reply via email to