forked from smartrics/RestFixture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.metrics.xml
344 lines (308 loc) · 13.3 KB
/
build.metrics.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?xml version="1.0" encoding="UTF-8"?>
<project name="RestFixture.metrics" default="all" basedir=".">
<property file="properties/${properties}.properties" />
<property file="properties/${user.name}.properties" />
<target name="inherit.properties" if="inherit.properties">
<property name="reports.dir" value="${reports}" />
<property name="src.dir" value="${src}" />
<property name="src.unit.dir" value="${src.unit}" />
<property name="etc.dir" value="${etc}" />
<property name="lib.dir" value="${lib}" />
<property name="build.dir" value="${build}" />
</target>
<target name="define.properties" unless="inherit.properties">
<property name="reports.dir" value="build/reports" />
<property name="src.dir" value="src/main/java" />
<property name="src.unit.dir" value="src/test/java" />
<property name="lib.dir" value="lib" />
<property name="etc.dir" value="etc" />
<property name="build.dir" value="build" />
</target>
<target name="define.shared.structures"
depends="inherit.properties, define.properties">
<echo message="Using reports.dir: ${reports.dir}" />
<echo message="Using src.dir: ${src.dir}" />
<echo message="Using etc.dir: ${etc.dir}" />
<echo message="Using lib.dir: ${reports.dir}" />
<echo message="Using build.dir: ${build.dir}" />
<property name="metrics.lib" value="${lib.dir}/test/metrics" />
<property name="metrics.config.dir" value="${etc.dir}/metrics" />
<property name="build.classes.main.dir"
value="${build.dir}/classes/main" />
<property name="metrics.report.dir" value="${reports.dir}/metrics" />
<property name="coverage.filter" value="" />
<property name="checkstyle.report.dir"
value="${metrics.report.dir}/checkstyle" />
<property name="jdepend.report.dir"
value="${metrics.report.dir}/jdepend" />
<property name="findbugs.report.dir"
location="${metrics.report.dir}/findbugs" />
<property name="coverage.report.dir"
location="${metrics.report.dir}/coverage" />
<property name="coverage.staging.dir"
location="${build.dir}/coverage-staging" />
<property name="pmd.report.dir" location="${metrics.report.dir}/pmd" />
<property name="cpd.report.dir" location="${metrics.report.dir}/cpd" />
<property name="crap4j.report.dir"
location="${metrics.report.dir}/crap4j" />
<property name="ckjm.report.dir"
location="${metrics.report.dir}/ckjm" />
<property name="coverage.enabled" value="true" />
<path id="metrics.classpath">
<fileset id="metrics.libs.id" dir="${metrics.lib}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="lib.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
<!-- captured in metrics.classpath -->
<exclude name="**/metrics/**/*.jar" />
</fileset>
</path>
<path id="coverage.test.classpath">
<pathelement location="${coverage.staging.dir}" />
<fileset dir="${lib.dir}">
<include name="**/emma*.jar" />
</fileset>
<path refid="test.classpath" />
</path>
</target>
<target name="all"
depends="init, cpd, pmd, findbugs, checkstyle, jdepend, ckjm, coverage, crap4j" />
<target name="init" depends="define.shared.structures" />
<target name="coverage" depends="init" unless="skip.metric.coverage">
<delete dir="${coverage.staging.dir}" />
<mkdir dir="${coverage.staging.dir}" />
<property name="emma.filter" value="${coverage.filter}" />
<path id="run.classpath">
<!-- class files we want to instrument -->
<pathelement location="${build.classes.main.dir}" />
</path>
<taskdef resource="emma_ant.properties"
classpathref="metrics.classpath" />
<emma enabled="true">
<instr instrpathref="run.classpath"
destdir="${coverage.staging.dir}"
metadatafile="${coverage.staging.dir}/metadata.emma"
merge="true">
<!-- note that coverage filters can be set through nested <filter>
elements as well: many of EMMA setting are 'mergeable' in the
sense that they can be specified multiple times and the result
is a union of all such values. Here we are not merging several
filters together but merely demonstrating that it is possible:
-->
<filter value="${emma.filter}" />
</instr>
</emma>
<junit errorproperty="test.failed" fork="false" printsummary="true">
<classpath refid="coverage.test.classpath" />
<batchtest fork="yes">
<fileset dir="${src.unit.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
<jvmarg value="-Demma.coverage.out.file=${coverage.staging.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
</junit>
<delete dir="${coverage.report.dir}" />
<mkdir dir="${coverage.report.dir}" />
<property name="coverage.threshold.method" value="70" />
<property name="coverage.threshold.block" value="80" />
<property name="coverage.threshold.line" value="80" />
<property name="coverage.threshold.class" value="100" />
<emma enabled="true">
<report sourcepath="${src.dir}"
sort="+block,+name,+method,+class"
metrics="method:${coverage.threshold.method},block:${coverage.threshold.block},line:${coverage.threshold.line},class:${coverage.threshold.class}">
<!-- collect all EMMA data dumps (metadata and runtime)
[this can be done via nested <fileset> fileset elements
or <file> elements pointing to a single file]:
-->
<fileset dir="${coverage.staging.dir}">
<include name="*.emma" />
</fileset>
<html outfile="${coverage.report.dir}/index.html"
depth="method"
columns="name,class,method,block,line" />
</report>
</emma>
</target>
<target name="check.findbugs.home" unless="findbugs.home">
<echo>Unknown findbugs home</echo>
<echo>Define 'findbugs.home' in your property file or run ant with -Dfindbugs.home. Its value should be the directory where findbugs has been installed.</echo>
<echo>Otherwise define the property 'skip.metric.findbugs' to skip findbugs from the build.</echo>
<fail message="findbugs.home not configured" />
</target>
<target name="findbugs" depends="init" unless="skip.metric.findbugs">
<antcall inheritall="true" target="check.findbugs.home" />
<delete dir="${findbugs.report.dir}" />
<mkdir dir="${findbugs.report.dir}" />
<path id="findbugs.classpath">
<fileset dir="${findbugs.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="findbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpathref="findbugs.classpath" />
<findbugs home="${findbugs.home}"
output="html"
outputFile="${findbugs.report.dir}/index.html"
jvmargs="-Xms512M -Xmx512M "
excludeFilter="${metrics.config.dir}/findBugs_exclude_filters.xml">
<sourcePath path="${src.dir}" />
<class location="${build.classes.main.dir}" />
<auxClasspath>
<pathelement location="${build.dir}/classes/cat" />
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</auxClasspath>
</findbugs>
</target>
<target name="ckjm" depends="init" unless="skip.metric.ckjm">
<!-- Chidamber and Kemerer Java Metrics (see http://www.spinellis.gr/sw/ckjm/) -->
<delete dir="${ckjm.report.dir}" />
<mkdir dir="${ckjm.report.dir}" />
<taskdef name="ckjm" classname="gr.spinellis.ckjm.ant.CkjmTask">
<classpath>
<pathelement location="${metrics.lib}/ckjm/ckjm-1.9.jar" />
</classpath>
</taskdef>
<ckjm outputfile="${ckjm.report.dir}/ckjm.xml"
format="xml"
classdir="${build.classes.main.dir}">
<include name="**/*.class" />
<exclude name="**/*Test.class" />
<extdirs refid="lib.classpath" />
</ckjm>
<xslt in="${ckjm.report.dir}/ckjm.xml"
style="${metrics.config.dir}/ckjm.xsl"
out="${ckjm.report.dir}/index_minimal.html" />
<xslt in="${ckjm.report.dir}/ckjm.xml"
style="${metrics.config.dir}/ckjm_extra.xsl"
out="${ckjm.report.dir}/index.html" />
</target>
<target name="pmd" depends="init" unless="skip.metric.pmd">
<delete dir="${pmd.report.dir}" />
<mkdir dir="${pmd.report.dir}" />
<taskdef name="pmd"
classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="metrics.classpath" />
<pmd rulesetfiles="imports,basic">
<formatter type="html"
toFile="${pmd.report.dir}/index.html"
toConsole="true" />
<formatter type="xml" toFile="${pmd.report.dir}/pmd.xml" />
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
<target name="cpd" depends="init" unless="skip.metric.cpd">
<delete dir="${cpd.report.dir}" />
<mkdir dir="${cpd.report.dir}" />
<taskdef name="cpd"
classname="net.sourceforge.pmd.cpd.CPDTask"
classpathref="metrics.classpath" />
<cpd minimumTokenCount="4"
format="xml"
outputFile="${cpd.report.dir}/cpd.xml">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
</cpd>
<xslt in="${cpd.report.dir}/cpd.xml"
style="${metrics.config.dir}/cpdhtml.xslt"
out="${cpd.report.dir}/index.html" />
</target>
<target name="jdepend" depends="init" unless="skip.metric.jdepend">
<delete dir="${jdepend.report.dir}" />
<mkdir dir="${jdepend.report.dir}" />
<!-- for this to work add jdepend-x.x.x.jar to your ANT_HOME/lib - note: if run in IDE, it's likely that ANT_HOME is that shipped with the IDE -->
<jdepend outputfile="${jdepend.report.dir}/jdepend-report.xml"
format="xml">
<classespath>
<pathelement location="${build.classes.main.dir}" />
</classespath>
</jdepend>
<xslt in="${jdepend.report.dir}/jdepend-report.xml"
out="${jdepend.report.dir}/index.html"
style="${metrics.config.dir}/jdepend.xsl" />
</target>
<target name="checkstyle"
unless="skip.metric.checkstyle"
depends="init"
description="Generates a report of code convention violations.">
<delete dir="${checkstyle.report.dir}" />
<mkdir dir="${checkstyle.report.dir}" />
<taskdef resource="checkstyletask.properties"
classpathref="metrics.classpath" />
<checkstyle config="${metrics.config.dir}/restfixture_checkstyle.xml"
failureProperty="checkstyle.failure"
failOnViolation="false"
classpathref="metrics.classpath">
<formatter type="xml"
tofile="${checkstyle.report.dir}/checkstyle_report.xml" />
<fileset dir="${src.dir}" includes="**/*.java" />
</checkstyle>
<xslt in="${checkstyle.report.dir}/checkstyle_report.xml"
out="${checkstyle.report.dir}/index.html"
style="${metrics.config.dir}/checkstyle-noframes-sorted.xsl" />
</target>
<target name="crap4j" depends="init" unless="skip.metric.crap4j">
<delete dir="${crap4j.report.dir}" />
<mkdir dir="${crap4j.report.dir}" />
<echo message="version 1.1.6 of Crap4j doesn't work on Windows - using patched version included in RestFixture/${metrics.lib}/crap4j" />
<property name="crap4j.home" value="${metrics.lib}/crap4j" />
<taskdef name="crap4j" classname="org.crap4j.anttask.Crap4jAntTask">
<classpath>
<fileset dir="${crap4j.home}/lib">
<include name="**/*.jar" />
</fileset>
<!-- by adding httpclient and dependencies, crap4j ant task will (try to) upload
the results to http://www.crap4j.org/benchmark/
effectively overriding whatever value is in server attribute... check the Crap4jAntTask#getServer - unbeliveable!!
-->
<!-- fileset dir="${lib.dir}/commons">
<include name="**/*.jar" />
</fileset -->
</classpath>
</taskdef>
<!-- patch allows passing crap4j.home to the task -->
<crap4j crap4jhome="${crap4j.home}"
projectdir="${basedir}"
outputDir="${crap4j.report.dir}"
dontTest="false"
debug="true">
<classes>
<pathElement location="${build.dir}/classes/main" />
</classes>
<srces>
<!-- The project's src folders -->
<pathElement location="${src.dir}/main/java" />
<pathElement location="${src.dir}/test/java" />
</srces>
<testClasses>
<pathElement location="${build.dir}/classes/unit" />
</testClasses>
<libClasspath>
<!-- Put the dependent paths and libraries here.
This is for stuff necessary to your project, but not stuff you want analyzed -->
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<!-- if you get errors loading any agitar classes, like the mock classes, add this entry - ->
<fileset dir="${crap4j.home}/lib/com.agitar.eclipse.api_4.2.0.401405/lib/ext">
<include name="**/*.jar" />
</fileset -->
</libClasspath>
</crap4j>
<delete file="crap_build.xml" />
<delete dir="agitar" />
</target>
</project>