蚂蚁:如何在目录中的每个文件执行一个命令? [英] Ant: How to execute a command for each file in directory?

查看:132
本文介绍了蚂蚁:如何在目录中的每个文件执行一个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个Ant构建执行命令,对目录中的每个文件。

我要寻找一个独立于平台的解决方案。

I want to execute a command from an Ant buildfile, for each file in a directory.
I am looking for a platform-independent solution.

我如何做到这一点?

当然,我可以在一些脚本语言编写一个脚本,
但是,这将进一步增加依赖到项目中。

推荐答案

使用<的foreach> 有一个嵌套的<文件集>

需要Foreach源蚂蚁的contrib

Foreach requires ant-contrib.

近期蚂蚁的contrib更新了例:

Updated Example for recent ant-contrib:

<target name="foo">
  <foreach target="bar" param="theFile">
    <fileset dir="${server.src}" casesensitive="yes">
      <include name="**/*.java"/>
      <exclude name="**/*Test*"/>
    </fileset>
  </foreach>
</target>

<target name="bar">
  <echo message="${theFile}"/>
</target>

这将antcall目标栏与$ {} theFile导致当前文件。

This will antcall the target "bar" with the ${theFile} resulting in the current file.

这篇关于蚂蚁:如何在目录中的每个文件执行一个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆