antfileset

File Enumeration with Ant


I feel like I'm missing something obvious at the moment. I want to collect a set of dirs / files together in Ant. I know I can do it using a fileset with an optional patternset inside it, but that involves searching for files based a specific criterion - filetype, name etc.

I already know the paths to the files I want to collect. I have n properties which reference these paths. I want a way to collect these paths in a fileset, though I cannot find a way to do it.

This represents what I want to achieve (I know it isn't valid code, but hopefully it will describe what I mean):

<fileset>
   <path>${src.dir}</path>
   <path>${test.dir}</path>
   <path>${third.party.src.dir}</path>
   <path>${bin.dir}</path>
   <path>${docs.build.txt}</path>
</fileset>

Solution

  • Thanks for the answer which works fine, however I managed to achieve the same thing even more simply using path with nested pathelements:

    <path
       id="srcdirs">
       <pathelement location="${src.dir}"/>
       <pathelement location="${test.dir}"/>
       <pathelement location="${assets.dir}"/>
    </path>