ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burgess, Benjamin" <BBurg...@tiaa-cref.org>
Subject RE: <fiilename> inside <fileset> doesn't have the expected behavior
Date Fri, 26 Aug 2005 19:27:26 GMT
Yes, filesets act as an <and> selector and this is intended.  This is a
well documented feature (http://ant.apache.org/manual/dirtasks.html -
scroll down to the Selectors header halfway down the page).  This is
default behavior.  If you want a different selector (such as <or> or
<not>) then you can specify it within your fileset.

Ben

-----Original Message-----
From: Dominique Devienne [mailto:ddevienne@gmail.com] 
Sent: Friday, August 26, 2005 2:50 PM
To: 'Ant Users List'
Subject: RE: <fiilename> inside <fileset> doesn't have the expected
behavior

> > "Tardif, Sebastien" <STARDIF@anacomp.com> 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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org



**************************************************************
This message, including any attachments, contains confidential information intended for a
specific individual and purpose, and is protected by law.  If you are not the intended recipient,
please contact sender immediately by reply e-mail and destroy all copies.  You are hereby
notified that any disclosure, copying, or distribution of this message, or the taking of any
action based on it, is strictly prohibited.
TIAA-CREF
**************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message