Information Technology Reference
In-Depth Information
LISTING 7-7
Using Simian in an Ant Task
1 <property name="reports.simian.dir"
value="${reports.dir}/simian-reports"/>
2 <property name="simian.output.filename" value="simian-results.xml"/>
3 <property name="simian.output.dir" value="${build.dir}"/>
4 <property name="simian.outputfile"
value="${simian.output.dir}/${simian.output.filename}"/>
5 <path id="simian.classpath">
6 <pathelement location="${lib.dir}/simian-2.2.17.jar"/>
7 </path
8 <target name="run-simian">
9 <delete dir="${reports.simian.dir}" quiet="true"/>
10 <mkdir dir="${reports.simian.dir}"/>
11 <taskdef resource="simiantask.properties"
classpathref="simian.classpath"/>
12 <simian threshold="4" language="java">
13 <fileset dir="${src.dir}" >
14 <include name="**/*.java"/>
15 <exclude name="**/*Test*"/>
16 </fileset>
17 <formatter type="xml" toFile="${simian.outputfile}"/>
18 </simian>
19 </target>
Line 1 —Defines a property for the location of the Simian dupli-
cation report.
Lines 2-4 —Define a simian.outputfile property. The XML
output file will be placed in the build directory.
Lines 5-7 —Create a Simian class path to load the Simian Ant
task.
Lines 9-10 —Clean up any previous reports and prepare for a
new duplication report.
Line 11 —Loads the Simian Ant task.
Line 12 —Invokes the Simian Ant task, with the duplication lan-
guage to check set to java . The threshold attribute sets the
minimum number of lines to be considered a match.
Lines 13-16 —Include the project source code; exclude any test
code.
Simian comes with an XSLT style sheet to enable transformation
of an XML report into HTML (see Listing 7-8).
Search WWH ::




Custom Search