Ant concat 文件集分隔符

cmc*_*loh 5 ant

在 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>
Run Code Online (Sandbox Code Playgroud)

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

<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>
Run Code Online (Sandbox Code Playgroud)

Iva*_*uev 4

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

<apply executable="echo"> <!-- run this command with each file name -->
  <fileset dir="/tmp" includes="**/*.*"/>
</apply>
Run Code Online (Sandbox Code Playgroud)

您还可以安装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>
Run Code Online (Sandbox Code Playgroud)