如何使用ant盘点任务countfilter [英] how to use ant count task countfilter
问题描述
我试着去计算该行出现的次数的这是否buildlist需要编译:真正的在文件中。我尝试以下code,但它不会拿起计数
Im trying to count the number of occurences of the line "Does this buildlist need compile: true" in a file. I tried the following code, but it does not pick up the count
<concat>
<fileset file="@{logPathInTestSetup}" />
<filterchain>
<tokenfilter>
<ct:countfilter property="noOfCompiledBuildlists" contains="Does this buildlist need compile:\s*(true)" override="true">
<ct:counteach propertyprefix="count." select="\1" />
</ct:countfilter>
</tokenfilter>
<ct:stopfilter />
</filterchain>
</concat>
当我尝试计算这种buildlist需要编译,柜台工作,我得到正确的值。所以绝对没有与正则表达式中的问题。是否有人可以帮忙吗?
谢谢,
Aarthi
When I try counting "Does this buildlist need compile:", the counter works and I get the correct value. So there is definitely a problem with the regex. Can someone please help? Thanks, Aarthi
推荐答案
您并不需要一些额外的工作,但是蚂蚁1.7.1+为&LT; CONCAT&GT;
必须的资源。结果
下面是从蚂蚁手动resourcecount 结果略有调整的例子
给定的输入,foobar.txt:结果
You don't need some extra task, but Ant 1.7.1+ as <concat>
has to be resource.
Here's a slightly adapted example from ant manual resourcecount
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
例如蚂蚁脚本:结果
example ant script :
<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 the lines that do not match, means negate your regex, simply use :
</linecontainsregexp negate="true">
这篇关于如何使用ant盘点任务countfilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!