From 6a2312cf4b1bba5ad98f6fefead38f393283a0e5 Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Mon, 24 Nov 2008 12:53:18 +0000 Subject: [PATCH] Example: counting lines in a file git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@720184 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTasks/resourcecount.html | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/manual/CoreTasks/resourcecount.html b/docs/manual/CoreTasks/resourcecount.html index 30fb57885..e191485ae 100644 --- a/docs/manual/CoreTasks/resourcecount.html +++ b/docs/manual/CoreTasks/resourcecount.html @@ -25,6 +25,7 @@

ResourceCount

+

Description

Display or set a property containing the size of a nested Resource Collection. @@ -63,12 +64,14 @@ No; default is "equal" +

Parameters specified as nested elements

Resource Collection

A single Resource Collection should be specified via a nested element or the refid attribute.

+

Examples

<resourcecount property="count.foo">
   <filelist dir="." files="foo,bar" />
@@ -77,6 +80,28 @@ should be specified via a nested element or the refid attribute.
 

Stores the number of resources in the specified filelist (two) in the property named count.foo.

+
+<project>
+  <property name="file" value="${ant.file}"/>
+  <resourcecount property="file.lines">
+    <tokens>
+      <concat>
+        <filterchain>
+          <tokenfilter>
+            <linetokenizer/>
+          </tokenfilter>
+        </filterchain>
+        <fileset file="${file}"/>
+      </concat>
+    </tokens>
+  </resourcecount>
+  <echo>The file '${file}' has ${file.lines} lines.</echo>
+</project>
+
+

Stores the number of lines of the current buildfile in the property file.lines. +Requires Ant 1.7.1+ as <concat> has to be resource.

+ +