Ant Integration
Three jMetra Ant tasks are provided. The parameters correspond to the jMetra command line interfaces, where the -options are now defined as attributes for the Ant tasks. The only key difference is that both collecting metrics from code and aggregating them are executed using the JMetraMaker command line class, but for execution with Ant, the metrics collection and the aggregation are done using two different Ant tasks.
Plugging jMetra into Ant
Step 1. You may plug these tasks into Ant explicitly by inserting the following into your Ant build file:
<taskdef name="jmetrametrics" classname="com.jmetra.tools.ant.JMetraMetricsTaskDef"/>
<taskdef name="jmetrametricsaggr" classname="com.jmetra.tools.ant.JMetraMetricsAggrTaskDef"/>
<taskdef name="jmetradoc" classname="com.jmetra.tools.ant.JMetraDocTaskDef"/>
or, you may integrating them implicitly by inserting them into the Ant Task properties resource bundle file located in the classpath at org/apache/tools/ant/taskdefs.
Step 2. Make sure you include the jmetra.jar and all its dependent jars on the Ant classpath.
jmetrametrics Ant Task
For the metrics collection, the options and their values correspond to the command line, exception for the option -rootsource. Since it took two parameters on the command line, one for the root directory and one for the source root keyword, it is represented in the Ant task as two distinct attributes. The Ant task attribute rootsource has the value of the source root, the first parameter on the command line. A second attribute, sourcekeyword, has the value of the source root keyword - the second parameter on the command line. See the example for clarification.
The output directory that was included after the options is now the Ant task attribute outputdir.
jmetrametricsaggr Ant Task
The option names correspond exactly to attribute names for the aggregation task.
The directory of the metrics files is specified with the Ant task attribute metricsdir. The output directory that was include after the options is now the Ant task attribute outputdir.
jmetradoc Ant Task
The option names correspond exactly to attribute names for the aggregation task.
The directory of the aggregate metrics files is specified with the Ant task attribute metricsdir. The output directory that was include after the options is now the Ant task attribute outputdir.
Examples
<jmetrametrics verbose="true" config="${projproducthome}/bin/jmetraconfig.xml" rootsource="${rootsource}" sourcekeyword="java" outputdir="${projmetricsdir}"/>
<jmetrametricsaggr verbose="true" config="${projproducthome}/bin/jmetraconfig.xml" metricsdir="${projmetricsdir}" outputdir="${projaggrmetricsdir}"/>
<jmetradoc verbose="true" package="com.jmetra;com.hcision.tools" aggrmetricsdir="${projaggrmetricsdir}" outputdir="${projmetricsdir}/docs" incparents="true"/>
Future documentation will include a detailed example of using Ant jMetra Tasks.
|