> > "Tardif, Sebastien" <[EMAIL PROTECTED]> wrote on 08/18/2005
> > 01:41:31 PM:
> >> This work:
> >> <copy todir="${jsp.dst.dir}">
> >>    <fileset dir="${dataviewservlet.dir}/sample">
> >>     <selector>
> >>      <or>
> >>       <filename name="DVMainLogoComponent.jsp"/>
> >>       <filename name="DVHitlistLogoComponent.jsp"/>
> >>       <filename name="DVHyperlinksComponent.jsp"/>
> >>      </or>
> >>     </selector>
> >>    </fileset>
> >> </copy>
> >>
> >> But this doesn't:
> >> <copy todir="${jsp.dst.dir}">
> >>    <fileset dir="${dataviewservlet.dir}/sample">
> >>       <filename name="DVMainLogoComponent.jsp"/>
> >>       <filename name="DVHitlistLogoComponent.jsp"/>
> >>       <filename name="DVHyperlinksComponent.jsp"/>
> >>     </fileset>
> >> </copy>
> >>
> >> And I received no error message so it's a valid Ant XML.
> >>
> >> Anybody understand why the second version doesn't work?
> >> What's the logic of the test?
> >>
> >> I'm using ANT 1.6.5 which is the latest official release.

Because of the code below in DirectoryScanner:

    protected boolean isSelected(String name, File file) {
        if (selectors != null) {
            for (int i = 0; i < selectors.length; i++) {
                if (!selectors[i].isSelected(basedir, name, file)) {
                    return false;
                }
            }
        }
        return true;
    }

For a file to be selected, all top-level selectors must be true, and thus
this behaves as an implicit <and>. Your file can't have 3 different names,
can it!?

That's why you need to wrap them into an <or> to get the equivalent of an
sequence of <include> (you don't need to further wrap the <or> into a
<selector>).

Why use <filename> instead of <include>? Because a set of or'd <filename>
can be inverted with a <not> for example, which you can't do with a
patternset, and also because combined with other selectors you can do
selections which you can't do with <patternset>+selectors. --DD


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

Reply via email to