Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant concat fileset separator

Tags:

ant

When using concat with fileset in Ant, how do I make an action happen for each element in the fileset. Such as, adding a string:

<fileset dir="${project.path.scripts-library}"
                excludes="!*.js, **/*.bak, **/dev.*"
>
    <type type="file" />
    <include name="**/0*.js" />
    <include name="**/1*.js" />
    <string>test</string>
</fileset>

Or echoing the current file name for each file in the fileset (and, how do I GET the file name for the current file???):

<fileset dir="${project.path.scripts-library}"
                excludes="!*.js, **/*.bak, **/dev.*"
>
    <echo file="${app.path.file}" 
            append="true"
            message=",${the.file.name}" />

    <type type="file" />
    <include name="**/0*.js" />
    <include name="**/1*.js" />
</fileset>
like image 698
cmcculloh Avatar asked Oct 10 '22 20:10

cmcculloh


1 Answers

I think there is no such thing in default ant. The closest one is <apply>, but it's system specific:

<apply executable="echo"> <!-- run this command with each file name -->
  <fileset dir="/tmp" includes="**/*.*"/>
</apply>

Also you can install ant-contrib to enable <for> task:

<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<for param="file">
  <path>
    <fileset dir="/tmp" includes="**/*.*"/>
  </path>
  <sequential> <!-- run any task here -->
    <echo>file [@{file}]</echo>
  </sequential>
</for>
like image 59
Ivan Nevostruev Avatar answered Oct 20 '22 11:10

Ivan Nevostruev