ResourceCount

Since Apache Ant 1.7

Description

Display or set a property containing the size of a nested resource collection. Can also be used as a condition.

Parameters

Attribute Description Required
Task Condition
property The property to set. No; by default, output value to the log Ignored
refid A reference to a resource collection. Yes, unless a nested resource collection is supplied
count Comparison count. Ignored Yes
when Comparison type: equal, eq, greater, gt, less, lt, ge (greater or equal), ne (not equal), le (less or equal). Ignored 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

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

<resourcecount property="count.foo">
  <filelist dir="." files="foo,bar"/>
</resourcecount>

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

<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>