Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to include / exclude a list of files by refid in ant?

Tags:

java

ant

We currently have an ant task that contains something similar to the following:

     <filelist dir="${css.dir}" id="ordered_css">
        <file name="interface/foo.css" />
        <file name="pages/monkey.css" />
        <file name="pages/ninja.css" />
        <file name="pages/sidebar.css" />
        <file name="pages/bar.css" />
        <file name="pages/baz.css" />
        <file name="pages/robot.css" />
     </filelist>

     <patternset id="exclude_css">
        <exclude name="interface/foo.css" />
        <exclude name="pages/monkey.css" />
        <exclude name="pages/ninja.css" />
        <exclude name="pages/sidebar.css" />
        <exclude name="pages/bar.css" />
        <exclude name="pages/baz.css" />
        <exclude name="pages/robot.css" />
     </patternset>

The task then references the patternset here:

 <fileset dir="${css.dir}" id="stuff_css" includes="*/stuff/*.css">
    <patternset refid="exclude_css" />
 </fileset>

And further down, it references the fileset here:

<concat destfile="build/all.css" append="false" force="yes">
    <filelist refid="ordered_css" />
    <fileset refid="stuff_css" />
</concat>

Is there a way to consolidate the two lists of files into one type that can be referenced in both places? So far I haven't been able to figure out a way, since the patternset contains excludes. I was hoping for a way to simply create a list of files and include or exclude the referenced list.

like image 367
braveterry Avatar asked Mar 04 '10 20:03

braveterry


1 Answers

A property can by used by both if you use the filelist files and patternset excludes attributes.

<property name="css_files" 
          value="interface/foo.css
                 pages/monkey.css 
                 pages/ninja.css 
                 pages/sidebar.css
                 pages/bar.css
                 pages/baz.css
                 pages/robot.css"/>

<filelist id="ordered_css" dir="${css.dir}" files="${css_files}"/>

<patternset id="exclude_css" excludes="${css_files}"/>
like image 136
leedm777 Avatar answered Oct 16 '22 02:10

leedm777