GMetrics - Ant Task


The GMetrics Ant Task is implemented by the org.gmetrics.ant.GMetricsTask class.


metricSetFileThe paths to a Groovy MetricSet DSL file. By default, the path specified is relative to the classpath, but it may be optionally prefixed by any of the valid prefixes, such as "file:" (to load from a relative or absolute filesystem path), or "http:". If not specified, it uses the set of Metrics defined by the Default MetricSet.NO

Report Nested Element

The <report> nested element defines the type and options for a report. It includes a type attribute and contains optional nested <option> elements.

NOTE: Currently, is the only report provided with GMetrics.

typeThe fully-qualified class name for the report class. This class must implement the interface.Yes

Option Nested Element

The <option> element is a child of the <report> element and defines a report-specific option for a report. See the Example below.

Fileset Nested Element

At least one fileset nested element is required, and is used to specify the source files that GMetrics should analyze. This is the standard Ant FileSet, and is quite powerful and flexible. See the Apache Ant Manual for more information on FileSets.


Here is an example Ant XML build file.

<taskdef name="gmetrics" classname="org.gmetrics.ant.GMetricsTask">
<target name="runGMetrics">

    <gmetrics metricSetFile="config/metricset.groovy">
        <report type="">
            <option name="outputFile" value="SampleGMetricsReport.html" />
            <option name="title" value="Sample" />
        <fileset dir="src">
            <include name="**/*.groovy"/>


Things to note:

  • The fileset specifies that all ".groovy" files are analyzed.
  • Remember that you need the log4j jar (and possibly a "" file) on the classpath.