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.
精彩评论