dynamicantfileset

How to pass multiple excludes for fileset in Ant as an input parameter?


I am using a fileset in Ant and I would like to have the things to exclude as an extracted property, like an array of strings(or just a comma-separated string). By doing this I can have a dynamic excludelist.

<!-- IN MY PROPERTY FILE -->

thingsToExclude = File1.java,File2.java,File3.java

<!-- IN MY BUILD.XML -->

<fileset dir="${somePath}" casesensitive="yes">
    <exclude name="File1.java"/>
    <exclude name="File2.java"/>
    <exclude name="File3.java"/>
</fileset>


<!-- WHAT I WOULD LIKE -->

<fileset dir="${somePath}" casesensitive="yes">
    <excludeList name="${thingsToExclude}"/>
</fileset>

Solution

  • Use excludesfile attribute of fileset and point to your property file, that should do the trick.

    excludesfile: the name of a file; each line of this file is taken to be an exclude pattern.

    Of course, you can use regex pattern like *.java to exclude a set of files as well.