开发者

check all files in fileset contain a string in ant

开发者 https://www.devze.com 2023-01-28 03:07 出处:网络
Can anyone provide an example of an ant build which che开发者_如何学运维cks if all files found by a fileset contain some token and do not contain some other token?

Can anyone provide an example of an ant build which che开发者_如何学运维cks 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...)


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>

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

0

精彩评论

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