ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: New copy like task
Date Sat, 15 Jun 2002 19:26:38 GMT
Just FTR, given the following files:
  dir1/a/b/c/snickerdoodle.txt
  dir1/a/b/bar.txt
  dir1/a/foo.txt
  dir2/a/b/c/somekinda.txt
  dir2/a/foo.txt
  dir3/a/b/bar.txt
  dir3/a/b/whatever.txt

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

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>
task:
    <fileset id="fs1" dir="dir1" includes="**/*.txt"/>
    <pathconvert pathsep="," refid="fs1" property="fs1">
      <map from="${dir1}${file.separator}" to=""/>
    </pathconvert>
    <fileset id="fs2" dir="dir2" includes="**/*.txt" excludes="${fs1}"/>
    <pathconvert pathsep="," refid="fs2" property="fs2">
      <map from="${dir2}${file.separator}" to=""/>
    </pathconvert>
    <fileset id="fs3" dir="dir3" includes="**/*.txt"
             excludes="${fs1},${fs2}"/>
    <pathconvert pathsep="," refid="fs3" property="fs3">
      <map from="${dir3}${file.separator}" to=""/>
    </pathconvert>

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

Diane



=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message