Ant concat文件集分隔符



在Ant中对文件集使用concat时,如何对文件集中的每个元素执行操作。例如,添加字符串:

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

或者回显文件集中每个文件的当前文件名(以及,如何获取当前文件的文件名??):

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

我认为默认ant中没有这样的东西。最接近的是<apply>,但它是特定于系统的:

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

此外,您还可以安装ant contrib来启用<for>任务:

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

最新更新