开发者

Ant concat fileset separator

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜