ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <>
Subject RE: appending to fileset
Date Tue, 10 Jun 2008 10:50:54 GMT

-----Original Message-----
From: Shawn Castrianni [] 
Sent: Monday, June 09, 2008 6:23 AM
To: 'Ant Users List'
Subject: appending to fileset

Is there a way to incrementally add files to a fileset?  I am building a
fileset by looping through an XML file and need to add files to a named
fileset one by one if they meet certain criteria.  Is this possible
without converting everything into paths or strings or stuff like that?

quick shot, untested, seems a bit long winded
maybe there's a better/shorter solution ?!

don't know your xml, so i took an example structure =

<!-- Import AntContrib -->
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Import XMLTask -->
<taskdef name="xmltask"

<target name="...">

<patternset id="basic_files" includes="*.txt **/*.properties"/>
   <fileset dir="Y:/test" id="namedfileset">
    <patternset refid="basic_files"/>

  <var name="filelist" value=""/>

  <xmltask source="your.xml">
    <call path="//file/*">
      <param path="name/text()" name="fname" />
          <your condition(s) goes here ... />
            <var name="filelist_tmp" value="${filelist}"/>
            <var name="filelist" unset="true"/>
            <var name="filelist" value="${filelist_tmp} @{fname}"/>

<patternset id="ext_files" includes="${filelist}"/>

<fileset dir="Y:/test" id="ext_namedfileset">
  <patternset refid="ext_files"/>
  <patternset refid="basic_files"/>

notes =
when using patternset you are more flexible
with the appropriate xpath expression and your condition(s) between
<actions>  <if> ... </if> ...</actions> you take control what is matched
whether the matched gets included in the space separated patternset
(don't know whether the blank at the end of ${filelist} is a problem !?)
Beside that you can put other tasks into the <actions .../> scope if

then later construct a fileset with the same dir as your first fileset
and include
both patternsets via refid= ... and finally you have your extended

you need =

Regards, Gilbert

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

View raw message