ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re: reverse glob mapper pattern?
Date Mon, 23 Sep 2002 05:59:45 GMT

Turns out that after some more clear thought and debugging that the issue 
lies in the fact that the paths provided by the fileset are cleaner than 
the ones defined by hand.  For instance, here are my variables used below:

<property name="root.dir" value="${basedir}/.." />
<property name="src.dir" value="${root.dir}/src" />
<property name="build.dir" value="${root.dir}/WEB-INF" />

So the physical result of these paths on my machine are:

src.dir   = D:\myclasses\repository\Barracuda_2002-09-19\Barracuda\src/../src
build.dir = 

However, the paths coming out of the fileset look like:


So, when I try to map like this:

<pathconvert pathsep="," property="src.sample.fs.copy" refid="src.sample.fs">
         <map from="${src.dir}${file.separator}sample." to=""/>

it doesn't match because the path I'm specifying, even though it points to 
the same physical place, is not a string match.

So, now my question is, how do I get around this issue?  I'd like to be 
able to use <mapper type="flatten"/>, but I'm not sure how to apply it to 
the fileset or to each individual path inside <pathconvert>?

Any suggestions?



At 10:37 AM 9/22/2002 -0500, you wrote:

>Hi Diane,
>Thanks for the response.  However, I tried you example out and, though it 
>seems like it *should* work the way you have it, there is something 
>wrong.  Here is what I am using:
>         <fileset dir="${src.dir}" id="src.sample.fs">
>             <present targetdir="${src.dir}">
>                 <mapper type="glob" from="sample.*" to="*" />
>             </present>
>         </fileset>
>         <fileset dir="${build.dir}" id="build.sample.fs">
>             <present targetdir="${build.dir}">
>                 <mapper type="glob" from="sample.*" to="*" />
>             </present>
>         </fileset>
>         <pathconvert pathsep="," property="src.sample.fs.copy" 
> refid="src.sample.fs">
>             <map from="${src.dir}${file.separator}sample." to=""/>
>         </pathconvert>
>         <property name="src.delete.includes" value="${src.sample.fs.copy}"/>
>         <echo message="${src.delete.includes}"/>
><!--        <delete>
>             <fileset dir="${src.dir}" includes="${src.delete.includes}"/>
>         </delete>-->
>In this case, the echo only produces this:
>      [echo] 
> D:\myclasses\repository\Barracuda_2002-09-19\Barracuda\src\
>My expectation was that it should have been "", not 
>"" that resulted from the <map> element.
>         <pathconvert pathsep="," property="build.sample.fs.copy" 
> refid="build.sample.fs">
>             <map from="${src.dir}${file.separator}sample." to=""/>
>         </pathconvert>
>         <property name="build.delete.includes" 
> value="${build.sample.fs.copy}"/>
>         <echo message="${build.delete.includes}"/>
><!--        <delete>
>             <fileset dir="${build.dir}" includes="${build.delete.includes}"/>
>         </delete>-->
>In this case, I have 5 sample.* files.  However, the echo only produces 
>the last 3 of them.  The first two are skipped.  Plus, we have the same 
>problem as the first case with returning sample.* files rather than the 
>expected *.
>      [echo] 
> D:\myclasses\repository\Barracuda_2002-09-19\Barracuda\WEB-INF\sample.log4j.xml,
>Like I said, it seems to me that the example you provided makes sense and 
>*should* work, but something seems to be a bit off here.
>Note:  I am using Ant-1.5.1-beta1.  Is this a bug that I'm running into here?
>At 05:16 PM 9/21/2002 -0700, you wrote:
>>--- Jacob Kjome <> wrote:
>> > So, I need to find all files that have a corresponding
>> > "sample.*" file and delete those.
>> >
>> > If I just use the following, it deletes the sample.* file, not the *
>> > file which is the opposite of what I want...
>> > [snip]
>> >                  <present present="both" targetdir="${src.dir}">
>> >                      <mapper type="glob" from="sample.*" to="*" />
>> >                  </present>
>>That's because it's returning what <present> says it will return, which is
>>just those files that do have equivalents -- it doesn't return the
>>equivalents as well.
>> > So, my question is, how do I set up a pattern where the fileset will get
>> > a list of the "*" files rather than the sample.* files to delete?
>>Generate the fileset the way you currently are, only do it outside of the
>><delete>, id it, then use <pathconvert> to get a comma-separated list
>>pass to 'includes' for the <delete>:
>>   <target name="doDelete">
>>     <fileset dir="${src.dir}" id="fs">
>>       <present targetdir="${src.dir}">
>>         <mapper type="glob" from="sample.*" to="*" />
>>       </present>
>>     </fileset>
>>     <pathconvert pathsep="," property="fs.sample" refid="fs">
>>       <map from="${src.dir}${file.separator}" to=""/>
>>     </pathconvert>
>>     <pathconvert pathsep="," property="fs.copy" refid="fs">
>>       <map from="${src.dir}${file.separator}sample." to=""/>
>>     </pathconvert>
>>     <property name="delete.includes" value="${fs.sample},${fs.copy}"/>
>>     <delete>
>>       <fileset dir="${src.dir}" includes="${delete.includes}"/>
>>     </delete>
>>   </target>
>>Do you Yahoo!?
>>New DSL Internet Access from SBC & Yahoo!
>>To unsubscribe, e-mail:   <>
>>For additional commands, e-mail: <>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message