You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Tardif, Sebastien" <ST...@anacomp.com> on 2005/08/18 19:41:31 UTC

inside doesn't have the expected behavior

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.

Re: inside doesn't have the expected behavior

Posted by Matt Benson <gu...@yahoo.com>.
I -still- do this occasionally and smack myself really
hard afterwards.  From the manual:

Selectors are available as nested elements within the
FileSet. If any of the selectors within the FileSet do
not select the file, the file is not considered part
of the FileSet. This makes a FileSet equivalent to an
<and> selector container.

This means that your second example tries to select
any file whose name is DVMainLogoComponent.jsp, and
whose name is also DVHitlistLogoComponent.jsp, and
whose name is also DVHyperlinksComponent.jsp .  Since
I am unaware of a filesystem on which this is
possible, nothing is selected.  :)

Incidentally, you don't need the extra set of
<selector> elements in your first example.

br,
Matt

--- "Tardif, Sebastien" <ST...@anacomp.com> wrote:

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


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


RE: inside doesn't have the expected behavior

Posted by Dominique Devienne <dd...@gmail.com>.
> > "Tardif, Sebastien" <ST...@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


Re: inside doesn't have the expected behavior

Posted by EJ Ciramella <ec...@archivas.com>.
why wouldn't you just use an includes="**/<filenamehere>"?

On Aug 18, 2005, at 1:59 PM, Jeffrey E Care wrote:

> Because the first one is part of a selector.
>
> --  
> Jeffrey E. Care (carej@us.ibm.com)
> WebSphere v7 Release Engineer
> WebSphere Build Tooling Lead (Project Mantis)
>
>
> "Tardif, Sebastien" <ST...@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.
>


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


Re: inside doesn't have the expected behavior

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Because the first one is part of a selector.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


"Tardif, Sebastien" <ST...@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.