开发者

Ant concat fileset separator

开发者 https://www.devze.com 2023-03-10 16:30 出处:网络
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:

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=",开发者_如何学C${the.file.name}" />

    <type type="file" />
    <include name="**/0*.js" />
    <include name="**/1*.js" />
</fileset>


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消