检查文件集中的所有文件在 ant 中包含一个字符串 [英] check all files in fileset contain a string in ant

查看:20
本文介绍了检查文件集中的所有文件在 ant 中包含一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能提供一个 ant 构建示例,该示例检查文件集找到的所有文件是否包含某个标记并且不包含其他标记?

Can anyone provide an example of an ant build which checks if all files found by a fileset contain some token and do not contain some other token?

(谷歌在这方面不是很有用,所以我在这里......)

(google has not been very useful with this, so here I am...)

推荐答案

我认为这可以使用 ant 的 resourcecontains 条件来完成,但我不确定它是否接受多个资源(请参阅 文档 了解详情).但是,可以使用 resourcecount 条件来完成:

I think this can be done using ant's resourcecontains condition, but I'm not sure it accept multiple resources (see the docs for details). However, it can be done using resourcecount contition:

<project name="Test" default="main" basedir=".">

  <patternset id="filestotest">
    <include name="*.c"/>
  </patternset>

  <target name="main">
    <condition property="contain">
      <resourcecount when="greater" count="0">
        <fileset dir=".">
          <patternset refid="filestotest"/>
          <contains text="main" casesensitive="yes"/>
        </fileset>
      </resourcecount>
    </condition>
    <condition property="donotcontain">
      <isfalse value="${contain}"/>
    </condition>
    <echo message="${contain}"/>
    <echo message="${donotcontain}"/>
  </target>
</project>

您可以使用 <resourcecount when="equal" count="0"> 来测试另一个令牌的相反条件.

You can use <resourcecount when="equal" count="0"> to test for the opposite condition for another token.

这篇关于检查文件集中的所有文件在 ant 中包含一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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