-
Notifications
You must be signed in to change notification settings - Fork 108
/
build.xml
487 lines (448 loc) · 23.3 KB
/
build.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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="zipwar" name="SimpleCustomerApp" xmlns:if="ant:if">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="C:/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<property name="jar.dir" value="build/jar"/>
<property name="war.dir" value="build/war"/>
<property name="zip.dir" value="build/zip"/>
<property name="build.dir" value="build/classes"/>
<property name="src.dir" value="src"/>
<property name="web.dir" value="WebContent"/>
<path id="Apache Tomcat v7.0 [Apache Tomcat v7.0].libraryclasspath">
<pathelement location="C:/apache-tomcat-7.0.70/lib/annotations-api.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/catalina-ant.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/catalina-ha.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/catalina-tribes.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/catalina.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/ecj-4.4.2.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/el-api.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/jasper-el.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/jasper.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/jsp-api.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/servlet-api.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-api.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-coyote.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-dbcp.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-i18n-es.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-i18n-fr.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-i18n-ja.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-jdbc.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat-util.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/tomcat7-websocket.jar"/>
<pathelement location="C:/apache-tomcat-7.0.70/lib/websocket-api.jar"/>
</path>
<path id="Web App Libraries.libraryclasspath"/>
<path id="EAR Libraries.libraryclasspath"/>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="SimpleCustomerApp.classpath">
<pathelement location="build/classes"/>
<path refid="Apache Tomcat v7.0 [Apache Tomcat v7.0].libraryclasspath"/>
<path refid="Web App Libraries.libraryclasspath"/>
<path refid="EAR Libraries.libraryclasspath"/>
<path refid="JUnit 4.libraryclasspath"/>
<pathelement location="${ECLIPSE_HOME}/plugins/javax.mail_1.4.0.v201005080615.jar"/>
</path>
<target name="init_1">
<mkdir dir="build/classes"/>
<copy includeemptydirs="false" todir="build/classes">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${jar.dir}" includes="**/*.jar" />
<fileset dir="${war.dir}" includes="**/*.war" />
<fileset dir="${zip.dir}" includes="**/*.zip" />
</delete>
</target>
<target name="build" depends="clean" description="Compile source tree java files">
<mkdir dir="${build.dir}"/>
<javac destdir="${build.dir}" includeAntRuntime="true" debug="true" debuglevel="vars,lines,source">
<src path="${src.dir}"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</javac>
</target>
<target name="getwar" depends="build">
<war destfile="${war.dir}\SimpleCustomerApp.war"
webxml = "${web.dir}\WEB-INF\web.xml">
<fileset dir = "${web.dir}">
<include name = "**/*.*"/>
</fileset>
<lib dir = "WebContent/WEB-INF/lib">
<include name = "**/*.jar"/>
</lib>
<classes dir = "build/classes"/>
</war>
</target>
<target depends="clean" name="cleanall"/>
<!--<target depends="build-subprojects,build-project" name="build"/>-->
<target depends="init_1" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="AllTests">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="com.room.sample.view.Test.AllTests" todir="${junit.output.dir}"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</junit>
</target>
<target name="com.room.sample.view.Test">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="com.room.sample.view.Test.CustomerTest" todir="${junit.output.dir}"/>
<test name="com.room.sample.view.Test.ValidateInputTest" todir="${junit.output.dir}"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</junit>
</target>
<target name="CustomerTest">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="com.room.sample.view.Test.CustomerTest" todir="${junit.output.dir}"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</junit>
</target>
<target name="ValidateInputTest">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="com.room.sample.view.Test.ValidateInputTest" todir="${junit.output.dir}"/>
<classpath refid="SimpleCustomerApp.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>
<property name="src.dir" value="src"/>
<property name="web.dir" value="WebContent"/>
<property name="lib.dir" value="${web.dir}/WEB-INF/lib"/>
<property name="build.dir" value="build/classes"/>
<property name="jar.dir" value="build/jar"/>
<property name="war.dir" value="build/war"/>
<property name="zip.dir" value="build/zip"/>
<property name="name" value="SimpleCustomerApp"/>
<property name="reports.dir" value="${basedir}/Reports" />
<property name="test.dir" location="${reports.dir}/BuildsUTCResults/src"/>
<property name="test.htmlreports.dir" location="${reports.dir}/BuildsUTCResults"/>
<property name="test.data.dir" location="${reports.dir}/BuildsUTCResults/data"/>
<property name="junit.class.name" value="com.room.sample.view.Test.AllTests"/>
<property name="test.classes.dir" location="src/com/room/sample/view/Test"/>
<!-- cobertura properties -->
<property name="cobertura.dir" value="C:/Jenkins/Utilities/JenkinsPlugin/cobertura/" />
<property name="classes.dir" value="build/classes" />
<property name="cobertura.ser.file" value="${basedir}/cobertura.ser" />
<property name="report.temp.dir" location="${reports.dir}/temp" />
<property name="instrumented.dir" value="${reports.dir}/instrumented" />
<property name="report.cobertura.dir" location="${reports.dir}/BuildsCodeCoverage" />
<property name="coverage.xml.dir" value="${report.cobertura.dir}/cobertura-xml" />
<property name="coverage.html.dir" value="${report.cobertura.dir}" />
<!-- findbugs properties -->
<property name="findbugs.home.dir" value="C:/Jenkins/Utilities/JenkinsPlugin/findbugs/findbugs-3.0.1/" />
<property name="report.findbugs.dir" location="${reports.dir}/SecurityAnalysis" />
<property name="bin.dir" location="${basedir}/bin" />
<!-- checkstyle properties-->
<property name="checkstyle.home.dir" location="C:/Jenkins/Utilities/JenkinsPlugin/findbugs/checkstyle-5.6-all/" />
<property name="report.checkstyle.dir" location="${reports.dir}/BuildsStaticCodeAnalysisReport" />
<!-- pmd properties-->
<property name="pmd.home.dir" value="C:/Jenkins/Utilities/JenkinsPlugin/pmd-5.0.5" />
<property name="report.pmd.dir" location="${reports.dir}/pmd" />
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs.home.dir}/lib/findbugs.jar"/>
<!-- Classpath to find java packages -->
<path id="master-classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<path id="classpath.src">
<pathelement location="src" />
</path>
<path id="classpath.junittest">
<path refid="master-classpath" />
<pathelement path="c:\junit\junit-4.12.jar" />
<pathelement location="${test.dir}" />
</path>
<path id="classpath.hamcrest">
<path refid="master-classpath" />
<pathelement path="c:\junit\hamcrest-all-1.3.jar" />
<pathelement location="${test.dir}" />
</path>
<path id="class.path.cobertura">
<path refid="master-classpath" />
<pathelement path="${cobertura.dir}/cobertura-1.9.4.1.jar" />
<pathelement path="${cobertura.dir}/lib/apache-log4j-1.2.15.jar" />
<pathelement path="${cobertura.dir}/lib/asm-tree-3.3.jar"/>
<pathelement path="${cobertura.dir}/lib/oro-2.0.8.jar"/>
<pathelement location="${cobertura.dir}" />
</path>
<taskdef classpathref="class.path.cobertura" resource="tasks.properties"/>
<path id="pmd2.classpath">
<pathelement location="${build}" />
<fileset dir="${pmd.home.dir}/lib/">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="pmd2.classpath" />
<target name="initRpt">
<mkdir dir="${instrumented.dir}"/>
<mkdir dir="${report.cobertura.dir}" />
<mkdir dir="${report.findbugs.dir}" />
<mkdir dir="${report.checkstyle.dir}" />
<!--<mkdir dir="${coverage.xml.dir}" />-->
<mkdir dir="${coverage.html.dir}" />
</target>
<target name="compile-test" depends="zipwar">
<mkdir dir="${test.dir}"/>
<javac srcdir="${test.dir}" destdir="${test.dir}" debug="true" includes="${src.dir}" includeAntRuntime="false">
<jvmarg if:set="usesplitverifier" value="-XX:-UseSplitVerifier" />
<classpath refid="master-classpath"/>
<classpath refid="classpath.src"/>
<classpath refid="classpath.junittest"/>
<classpath refid="class.path.cobertura" />
<include name="**/*.java"/>
</javac>
</target>
<!-- junit target -->
<target name="junit" depends="compile-test">
<mkdir dir="${test.htmlreports.dir}"/>
<mkdir dir="${test.data.dir}"/>
<junit fork="no" haltonfailure="no" showoutput="yes" printsummary="true">
<test name="${junit.class.name}" todir="${test.data.dir}"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<classpath refid="master-classpath" />
<classpath refid="classpath.src" />
<classpath refid="classpath.junittest" />
<classpath refid="classpath.hamcrest" />
</junit>
<junitreport todir="${test.htmlreports.dir}">
<fileset dir="${test.data.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.htmlreports.dir}"/>
</junitreport>
</target>
<!-- cobertura target -->
<target name="cover-test" depends="instrument-classes">
<junit dir="./" failureproperty="test.failed" printSummary="true"
fork="yes" haltonerror="false" showoutput="yes">
<echo>Cover test execution starts</echo>
<!-- Normally you can create this task by copying your existing JUnit
target, changing its name, and adding these next two lines.
You may need to change the locations to point to wherever
you've put the cobertura.jar file and the instrumented classes. -->
<classpath location="${cobertura.dir}/cobertura-1.9.4.1.jar"/>
<!-- <classpath refid="class.path.cobertura" /> -->
<classpath location="${instrumented.dir}"/>
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<pathelement path="${test.classes.dir}" />
<pathelement path="${classes.dir}" />
</classpath>
<batchtest todir="${test.data.dir}">
<fileset dir="${src.dir}">
<include name="**/*Tests.java" />
</fileset>
</batchtest>
</junit>
</target>
<!-- -->
<target name="junit-cob"
depends="clean, build, instrument-classes"
description="Run all junit test cases."
>
<mkdir dir="${report.cobertura.dir}" />
<mkdir dir="${report.temp.dir}" />
<junit fork="yes" haltonfailure="no" showoutput="yes" printsummary="withOutAndErr">
<jvmarg if:set="usesplitverifier" value="-XX:-UseSplitVerifier" />
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${cobertura.ser.file}" />
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented.dir}" />
<classpath location="${classes.dir}" />
<!--
The instrumented classes reference classes used by the
Cobertura runtime, so Cobertura and its dependencies
must be on your classpath.
-->
<classpath refid="class.path.cobertura" />
<classpath refid="classpath.junittest" />
<classpath refid="classpath.hamcrest" />
<classpath refid="master-classpath" />
<formatter type="xml" />
<test name="${junit.class.name}" todir="${test.data.dir}" if="testcase" />
<batchtest todir="${report.temp.dir}" unless="testcase">
<fileset dir="${src.dir}">
<include name="**/*Tests.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="instrument-classes" depends="junit">
<delete file="${cobertura.ser.file}"/>
<delete dir="${instrumented.dir}" />
<mkdir dir="${instrumented.dir}" />
<!-- Instrument the application classes, writing the instrumented classes into ${build.instrumented.dir}. -->
<echo>Reached Instrument</echo>
<cobertura-instrument todir="${instrumented.dir}" datafile="${cobertura.ser.file}">
<ignore regex="org.apache.log4j.*" />
<fileset dir="${classes.dir}">
<!-- Instrument all the application classes, but don't instrument the test classes. -->
<include name="**/*.class" />
<exclude name="**/*Test*.class" />
</fileset>
</cobertura-instrument>
</target>
<target name="report-cobertura" depends="junit-cob" description="Generate a report on error analysis.">
<echo>Reached report cobertura</echo>
<delete dir="${report.cobertura.dir}" />
<mkdir dir="${report.cobertura.dir}" />
<mkdir dir="${coverage.xml.dir}" />
<mkdir dir="${coverage.html.dir}" />
<cobertura-report format="html" datafile="${cobertura.ser.file}" destdir="${coverage.html.dir}">
<fileset dir="${src.dir}">
<!-- Instrument all the application classes, but don't instrument the test classes. -->
<include name="**/*.java" />
<exclude name="**/*Test.java" />
</fileset>
</cobertura-report>
<cobertura-report format="xml" datafile="${cobertura.ser.file}" destdir="${coverage.xml.dir}">
<fileset dir="${src.dir}">
<include name="**/*.java" />
<exclude name="**/*Test*.java" />
</fileset>
</cobertura-report>
</target>
<!-- test Target -->
<target name="test" depends="junit">
</target>
<target name="test-all" depends="initRpt,report-cobertura,report-checkstyle,report-findbugs,junit">
</target>
<!-- findbugs target -->
<target name="findbugs"
depends="compile-test"
description="Run code analysis over code to check for problems." >
<!-- Fail this target if FindBugs is not installed. -->
<available file="${findbugs.home.dir}/lib/findbugs.jar" property="findbugs.available" />
<fail unless="findbugs.available" message="Error: FINDBUGS_HOME not set or findbugs.jar not found." />
<echo>Reached findbugs</echo>
<delete dir="${report.findbugs.dir}" />
<mkdir dir="${report.findbugs.dir}" />
<findbugs home="${findbugs.home.dir}"
output="xml"
outputFile="${report.findbugs.dir}\findbugs-test.xml">
<auxClasspath>
<!-- Third party jars classpath -->
<fileset dir="${lib.dir}">
<include name="*/**"/>
<include name="*.jar"/>
</fileset>
</auxClasspath>
<class location="${classes.dir}"/>
<!-- Class files you're analyzing -->
<sourcePath path="${src.dir}"/>
<!-- Source directory -->
</findbugs>
</target>
<target name="report-findbugs" depends="findbugs" description="Generate a report on error analysis.">
<xslt in="${report.findbugs.dir}/findbugs-test.xml"
style="${findbugs.home.dir}/src/xsl/fancy.xsl"
out="${report.findbugs.dir}\findbugs-default.html"/>
</target>
<!-- checkstyle target-->
<target name="report-checkstyle"
description="Generate a report of code convention violations.">
<taskdef resource="checkstyletask.properties"
classpath="${checkstyle.home.dir}/checkstyle-5.6-all.jar"
/>
<!-- run verification of installation-->
<available file="${checkstyle.home.dir}/checkstyle-5.6-all.jar"
property="checkstyle.available"
/>
<fail unless="checkstyle.available"
message="Error: CHECKSTYLE_HOME not set or checkstyle-5.6-all.jar not found."
/>
<!-- run analysis-->
<delete dir="${report.checkstyle.dir}" />
<mkdir dir="${report.checkstyle.dir}" />
<echo>Reached checkstyle</echo>
<checkstyle config="${checkstyle.home.dir}/sun_checks.xml"
failureProperty="checkstyle.failure"
failOnViolation="false" >
<formatter type="xml" tofile="${report.checkstyle.dir}/checkstyle_report.xml" />
<fileset dir="${src.dir}" includes="**/*.java" />
</checkstyle>
<xslt in="${report.checkstyle.dir}/checkstyle_report.xml"
out="${report.checkstyle.dir}/checkstyle_report.html"
style="${checkstyle.home.dir}/checkstyle-noframes.xsl"
/>
</target>
<!-- pmd target-->
<target name="report.pmd">
<mkdir dir="${report.pmd.dir}" />
<pmd rulesetfiles="imports">
<formatter type="xml" toFile="${report.pmd.dir}/pmd_report.xml" />
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
<xslt in="${report.pmd.dir}/pmd_report.xml"
style="${pmd.home.dir}/etc/xslt/pmd-report-per-class.xslt"
out="${report.pmd.dir}/pmd_report.html"
/>
</target>
<target name="zipwar" depends="getwar">
<zip destfile="${zip.dir}/SimpleCustomerApp.zip"
basedir="${war.dir}"
includes="**/*.war">
</zip>
</target>
</project>