Search code examples
antbuild.xmlfileset

ANT: several filesets for the javac task


I have a ANT build file with two different filesets:

<fileset id="fs1">  <include name="source1\**" />  </fileset>
<fileset id="fs2">  <include name="source2\**" />  </fileset>

and want to use both of them in the same javac task.

Of course, I could write

<javac ...>
     <include name="source1\**" />
     <include name="source2\**" />
</javac>

but I want the selection of the files occurs outside, because my javac-task will be called several times with different parameters.

A solution would be to copy all the files in a temp directory and call javac on it. But you will admit it is not very satisfying...

More over: is there a solution to concatenate two filesets in a single one?


Solution

  • I've found a solution, using patternset.

    <patternset id="ps1">  <include name="source1\**" />  </patternset>
    <patternset id="ps2">  <include name="source2\**" />  </patternset>
    
    <javac ...>
      <patternset>
        <patternset refid="ps1" />
        <patternset refid="ps2" />
      </patternset>
    </javac>