You do not need an additional task, but Ant 1.7.1+ as a <concat>
should be a resource.
Here is a slightly adapted example from ant manual resource number
given input, foobar.txt:
Does this buildlist need compile: true whatever Does this buildlist need compile: false The quick brown fox jumps over the lazy dog Does this buildlist need compile: true Does this buildlist need compile: false Does this buildlist need compile: true foo blablabla Does this buildlist need compile: true
Ant script example:
<project> <property name="file" value="foobar.txt"/> <resourcecount property="file.lines"> <tokens> <concat> <filterchain> <linecontainsregexp> <regexp pattern="Does this buildlist need compile:\s*(true)"/> </linecontainsregexp> </filterchain> <fileset file="${file}"/> </concat> </tokens> </resourcecount> <echo>The file '${file}' has ${file.lines} lines.</echo> </project>
:
[echo] The file 'foobar.txt' has 4 lines.
EDIT
To get strings that don't match means to deny your regular expression, just use:
</linecontainsregexp negate="true">
Rebse source share