ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: New copy like task
Date Sat, 15 Jun 2002 19:26:38 GMT
Just FTR, given the following files:

For Ant1.5, using Selectors:
    <fileset id="fs1" dir="dir1" includes="**/*.txt"/>
    <fileset id="fs2" dir="dir2" includes="**/*.txt">
        <present targetdir="dir1"/>
    <fileset id="fs3" dir="dir3" includes="**/*.txt">
        <present targetdir="dir1"/>
        <present targetdir="dir2"/>

results in (<pathconvert>'d to echo the filesets out, which is why the
filesets have id's -- you don't actually need those otherwise, since the
<fileset>'s would be inside the <copy> task [also, the leading paths have
been lopped off, to make the output easier to read]):
     [echo] fs1 = a\b\c\snickerdoodle.txt,a\b\bar.txt,a\foo.txt
     [echo] fs2 = a\b\c\somekinda.txt
     [echo] fs3 = a\b\whatever.txt

For pre-1.5, you can use <pathconvert> to generate a list of files to use
for the 'excludes' attr of each successive <fileset> to achieve the same
result. You do have to id them in this case, and you need to set a
property for each of dir1, dir2, and dir3, in order to do the lopping off
of the leading path. The resultant properties can then be used as the list
of files for the 'includes' attribute of the <fileset>'s in the <copy>
    <fileset id="fs1" dir="dir1" includes="**/*.txt"/>
    <pathconvert pathsep="," refid="fs1" property="fs1">
      <map from="${dir1}${file.separator}" to=""/>
    <fileset id="fs2" dir="dir2" includes="**/*.txt" excludes="${fs1}"/>
    <pathconvert pathsep="," refid="fs2" property="fs2">
      <map from="${dir2}${file.separator}" to=""/>
    <fileset id="fs3" dir="dir3" includes="**/*.txt"
    <pathconvert pathsep="," refid="fs3" property="fs3">
      <map from="${dir3}${file.separator}" to=""/>

(Although, clearly, the 1.5 approach is a lot more straightforward :)



Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message