-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
514 lines (481 loc) · 21.8 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
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<!--
* Copyright 2015 Roland Gisler
* Hochschule Luzern Technik & Architektur, Switzerland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<project name="template" default="build" basedir="." xmlns:jacoco="antlib:org.jacoco.ant" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Properties hierarchisch einlesen -->
<property file="${basedir}/build.properties" />
<property file="${basedir}/../build.properties" />
<property file="${user.home}/build.properties" />
<!-- project-properties (last defaults), SET THEM IN build.properties!) -->
<property name="proj.modul" value="" />
<property name="proj.group" value="" />
<property name="proj.name" value="template" />
<property name="proj.version" value="0.0.0" />
<property name="proj.startclass" value="" />
<property name="proj.autor" value="" />
<property name="proj.encoding" value="UTF-8" />
<!-- environment -->
<property environment="env" />
<!-- setting source location -->
<property name="config" location="${basedir}/config" />
<property name="lib" location="${basedir}/lib" />
<property name="libtest" location="${lib}/test" />
<property name="src" location="${basedir}/src" />
<property name="src.main" location="${src}/main" />
<property name="src.test" location="${src}/test" />
<property name="src.main.java" location="${src.main}/java" />
<property name="src.test.java" location="${src.test}/java" />
<property name="src.main.resources" location="${src.main}/resources" />
<property name="src.test.resources" location="${src.test}/resources" />
<!-- setting target locations -->
<property name="target" location="${basedir}/build" />
<property name="classes" location="${target}/classes" />
<property name="test-classes" location="${target}/classes-test" />
<property name="dist" location="${target}/dist" />
<property name="generated" location="${target}/generated" />
<property name="classycle" location="${target}/classycle" />
<property name="javadoc" location="${target}/javadoc" />
<property name="test" location="${target}/test" />
<property name="coverage" location="${target}/coverage" />
<property name="checkstyle" location="${target}/checkstyle" />
<property name="pmd" location="${target}/pmd" />
<!-- setting general properties -->
<property name="proj.java.version" value="1.8" />
<!-- calculated properties -->
<property name="distname" value="${proj.name}-${proj.version}" />
<property name="coverage.data" value="${coverage}/jacoco.exec" />
<property name="checkstyle.config.file" value="${config}/checkstyle/checkstyle.xml" />
<property name="pmd.config.file" value="${config}/pmd/pmd_hslu.xml" />
<property name="ivy.file" value="${config}/ivy/ivy.xml" />
<!-- define runtime libraries -->
<path id="libset.runtime">
<fileset dir="${lib}">
<include name="**/*.jar" />
<exclude name="test/*.jar" />
</fileset>
</path>
<!-- define test libraries -->
<path id="libset.test">
<fileset dir="${libtest}">
<include name="*.jar" />
</fileset>
<fileset dir="${config}/jacoco/lib">
<include name="*.jar" />
</fileset>
</path>
<!-- Taskdef for Ivy -->
<path id="ivy.lib.path">
<fileset dir="${config}/ivy/lib" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
<!-- Taskdef for coverage -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${config}/jacoco/lib/jacocoant.jar" />
</taskdef>
<!-- Taskdef for QSReporter -->
<path id="qsreporter.lib.path">
<fileset dir="${config}/qsreporter/lib" includes="*.jar" />
</path>
<taskdef name="qsreporter" classname="ch.gitik.qsreporter.QSReporterTask" classpathref="qsreporter.lib.path" />
<!-- Include (optional) additional targets -->
<import file="${config}/ant/build-addons.xml" optional="true" />
<!--====================================================================-->
<!-- info -->
<!--====================================================================-->
<target name="info" description="display runtime version info">
<echo message="=============================================================" level="info" />
<echo message=" Building '${ant.project.name}'" level="info" />
<echo message="=============================================================" level="info" />
<echo message=" Java Version : ${java.version} ${java.vendor} on ${os.name}" level="info" />
<echo message=" ANT Version : ${ant.version}" level="info" />
<echo message=" Source : Level ${proj.java.version} (encoding: ${proj.encoding})" level="info" />
<echo message=" UserConfDir : ${user.home}" level="info" />
</target>
<!-- ================================================================== -->
<!-- Target: init -->
<!-- ================================================================== -->
<target name="init" depends="info" description="create directory structure">
<mkdir dir="${classes}" />
<mkdir dir="${test-classes}" />
<mkdir dir="${generated}" />
</target>
<!-- ================================================================== -->
<!-- Target: resolve -->
<!-- ================================================================== -->
<target name="resolve" depends="init" description="resolve dependencies">
<ivy:resolve file="${ivy.file}" conf="compile,test" />
<path id="libset.ivy.compile">
<ivy:resources file="${ivy.file}" conf="compile" />
</path>
<path id="libset.ivy.test">
<ivy:resources file="${ivy.file}" conf="test" />
</path>
<ivy:retrieve file="${ivy.file}" conf="compile,test" pattern="${target}/libext/[conf]/[artifact].[ext]" />
</target>
<!-- ================================================================== -->
<!-- Target: generate -->
<!-- ================================================================== -->
<target name="generate" depends="resolve" description="generate source code">
</target>
<!-- ================================================================== -->
<!-- Target: compile -->
<!-- ================================================================== -->
<target name="compile" depends="generate" description="compile the source and tests ">
<echo message="Compiling for sourcelevel ${proj.java.version} and ${proj.encoding}-encoding..." level="info" />
<javac destdir="${classes}"
source="${proj.java.version}"
target="${proj.java.version}"
encoding="${proj.encoding}"
listfiles="true"
debug="true"
includeAntRuntime="false"
fork="true">
<src path="${src.main.java}" />
<src path="${generated}" />
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:static" />
<compilerarg value="-Xlint:unchecked" />
<classpath>
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
</classpath>
</javac>
<copy todir="${classes}" overwrite="true">
<fileset dir="${src.main.resources}">
<include name="**/*" />
</fileset>
</copy>
<javac srcdir="${src.test.java}"
destdir="${test-classes}"
source="${proj.java.version}"
target="${proj.java.version}"
encoding="${proj.encoding}"
listfiles="true"
debug="true"
includeAntRuntime="false"
fork="true">
<compilerarg value="-Xlint:deprecation" />
<compilerarg value="-Xlint:static" />
<compilerarg value="-Xlint:unchecked" />
<classpath>
<pathelement path="${classes}" />
<path refid="libset.test" />
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
<path refid="libset.ivy.test" />
</classpath>
</javac>
</target>
<!-- ================================================================== -->
<!-- Target: jar -->
<!-- ================================================================== -->
<target name="jar" depends="compile" description="create jar">
<mkdir dir="${target}/lib" />
<jar jarfile="${target}/lib/${distname}.jar" basedir="${classes}">
<manifest>
<attribute name="Implementation-Title" value="${proj.name}" />
<attribute name="Implementation-Version" value="${proj.version}" />
<attribute name="Implementation-Vendor" value="HSLU" />
<attribute name="Implementation-User" value="${proj.autor}" />
<attribute name="Built-By" value="${proj.autor}" />
<attribute name="Sealed" value="false" />
<attribute name="Main-Class" value="${proj.startclass}" />
</manifest>
</jar>
</target>
<!-- ================================================================== -->
<!-- Target: test -->
<!-- ================================================================== -->
<target name="test" depends="jar" description="executes unittests">
<mkdir dir="${test}" />
<mkdir dir="${coverage}" />
<touch file="${coverage.data}" />
<jacoco:agent property="jacoco.vm.param" destfile="${coverage.data}" />
<junit printsummary="off"
haltonfailure="false"
fork="true"
forkmode="once"
showoutput="true"
failureproperty="test.failed">
<jvmarg value="${jacoco.vm.param}" />
<sysproperty key="proj.basedir" value="${basedir}" />
<formatter usefile="false" type="brief" />
<formatter type="xml" />
<batchtest todir="${test}">
<fileset dir="${src.test.java}">
<include name="**/*Test.java" />
<exclude name="**/AllTest.java" />
</fileset>
</batchtest>
<classpath>
<path location="${src.test.resources}" />
<path location="${test-classes}" />
<path location="${classes}" />
<path refid="libset.test" />
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
<path refid="libset.ivy.test" />
</classpath>
</junit>
<test.report />
<coverage.report />
<fail message="Unit tests FAILED!" if="test.failed" />
</target>
<!-- ================================================================== -->
<!-- Target: integration-test -->
<!-- ================================================================== -->
<target name="integration-test" depends="test" description="executes integration tests">
<junit printsummary="off"
haltonfailure="false"
fork="true"
forkmode="once"
showoutput="true"
failureproperty="test.failed">
<jvmarg value="${jacoco.vm.param}" />
<sysproperty key="proj.basedir" value="${basedir}" />
<formatter usefile="false" type="brief" />
<formatter type="xml" />
<batchtest todir="${test}">
<fileset dir="${src.test.java}">
<include name="**/*IT.java" />
</fileset>
</batchtest>
<classpath>
<path location="${src.test.resources}" />
<path location="${test-classes}" />
<path location="${classes}" />
<path refid="libset.test" />
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
<path refid="libset.ivy.test" />
</classpath>
</junit>
<test.report />
<coverage.report />
<fail message="Integrations tests FAILED!" if="test.failed" />
</target>
<!-- ================================================================== -->
<!-- Target: checkstyle -->
<!-- ================================================================== -->
<target name="checkstyle" depends="init" description="checkstyle report" unless="${checkstyle.disable}">
<path id="libset.checkstyle">
<ivy:resources file="${ivy.file}" conf="checkstyle" />
</path>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpathref="libset.checkstyle" />
<mkdir dir="${checkstyle}" />
<checkstyle config="${checkstyle.config.file}" failonviolation="false">
<fileset dir="${src.main.java}" includes="**/*.java" />
<fileset dir="${src.test.java}" includes="**/*.java" />
<formatter type="xml" toFile="${checkstyle}/checkstyle.xml" />
</checkstyle>
<xslt in="${checkstyle}/checkstyle.xml"
out="${checkstyle}/index.html"
style="${config}/checkstyle/style/checkstyle-noframes-severity-sorted.xsl" />
<qsreporter checkstylexml="${checkstyle}/checkstyle.xml" />
</target>
<!-- ================================================================== -->
<!-- Target: classycle -->
<!-- ================================================================== -->
<target name="classycle" depends="jar" description="classycle report" unless="${classycle.disable}">
<path id="libset.classycle">
<fileset dir="${config}/classycle/lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef name="classycleReport" classname="classycle.ant.ReportTask" classpathref="libset.classycle" />
<mkdir dir="${classycle}" />
<classycleReport reportFile="${classycle}/classycle.xml">
<fileset dir="${target}/lib/">
<include name="${distname}.jar" />
</fileset>
</classycleReport>
<xslt in="${classycle}/classycle.xml"
out="${classycle}/index.html"
style="${config}/classycle/style/reportXMLtoHTML.xsl" />
<copy todir="${classycle}/images">
<fileset dir="${config}/classycle/images" includes="*.png" />
</copy>
<qsreporter classyclexml="${classycle}/classycle.xml" />
</target>
<!-- ================================================================== -->
<!-- Target: pmd -->
<!-- ================================================================== -->
<target name="pmd" depends="init" description="pmd report" unless="${pmd.disable}">
<path id="libset.pmd">
<path id="libset.checkstyle">
<ivy:resources file="${ivy.file}" conf="pmd" />
</path>
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="libset.pmd" />
<mkdir dir="${pmd}" />
<pmd rulesetfiles="${pmd.config.file}">
<sourceLanguage name="java" version="${proj.java.version}" />
<formatter type="xml" toFile="${pmd}/pmd.xml" />
<fileset dir="${src.main.java}" includes="**/*.java" />
<fileset dir="${src.test.java}" includes="**/*.java" />
</pmd>
<xslt in="${pmd}/pmd.xml" out="${pmd}/index.html" style="${config}/pmd/style/pmd-report-per-class.xslt" />
<qsreporter pmdxml="${pmd}/pmd.xml" />
</target>
<!-- ================================================================== -->
<!-- Target: javadoc -->
<!-- ================================================================== -->
<target name="javadoc" depends="resolve" description="create JavaDoc">
<mkdir dir="${javadoc}" />
<javadoc defaultexcludes="true"
private="true"
destdir="${javadoc}"
encoding="${proj.encoding}"
charset="${proj.encoding}"
docencoding="${proj.encoding}"
author="true"
version="true"
use="true"
windowtitle="${proj.name}"
overview="${src.main.java}/overview.html">
<classpath>
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
</classpath>
<doctitle><![CDATA[<h1>Dokumentation</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright 2015 Hochschule Luzern Technik & Architektur, Switzerland</i>]]></bottom>
<fileset dir="${src.main.java}">
<include name="**/*.java" />
</fileset>
<link href="http://docs.oracle.com/javase/8/docs/api/" />
</javadoc>
<zip destfile="${javadoc}/javadoc.zip">
<fileset dir="${javadoc}">
<include name="**/*" />
<exclude name="**/*.zip" />
</fileset>
</zip>
</target>
<!-- ================================================================== -->
<!-- Target: dist -->
<!-- Hinweis: Spezielle Reihenfolge: QS-Reports auch erstellen wenn -->
<!-- Fehler vorhanden sind (compile, test etc.) -->
<!-- ================================================================== -->
<target name="dist" depends="clean, report, jar, build" description="create distributions">
<mkdir dir="${target}/dist" />
<zip destfile="${target}/dist/${distname}-bin.zip">
<zipfileset dir="${basedir}" prefix="${distname}">
<include name="*.txt" />
</zipfileset>
<zipfileset dir="${target}/lib" prefix="${distname}/lib">
<include name="*.jar" />
</zipfileset>
<zipfileset dir="${lib}" prefix="${distname}/lib">
<include name="*.jar" />
<exclude name="ant*.jar" />
</zipfileset>
<zipfileset dir="${javadoc}" prefix="${distname}/doc">
<include name="**/*.*" />
<exclude name="javadoc.zip" />
</zipfileset>
</zip>
<zip destfile="${target}/dist/${distname}-src.zip">
<zipfileset dir="${basedir}" prefix="${proj.name}">
<include name="**/*" />
<exclude name="src/site/**" />
<exclude name="build/**" />
<exclude name="nbproject/**" />
<exclude name="eclipse/**" />
<exclude name="target/**" />
<exclude name=".*/**" />
<exclude name="*.jenkins" />
<exclude name="release.properties" />
<exclude name="pom.xml" />
<exclude name="*.gradle" />
<exclude name="*.iml" />
<exclude name="**/build-addons.xml" />
</zipfileset>
</zip>
</target>
<!-- ================================================================== -->
<!-- Target: run -->
<!-- ================================================================== -->
<target name="run" depends="jar" description="run the project">
<java classname="${proj.startclass}" fork="true">
<classpath>
<path location="${target}/lib/${distname}.jar" />
<path refid="libset.runtime" />
<path refid="libset.ivy.compile" />
</classpath>
</java>
</target>
<!-- ================================================================== -->
<!-- Target: clean -->
<!-- ================================================================== -->
<target name="clean" depends="info" description="clean up">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${target}" excludes="eclipse/**/*" />
</delete>
</target>
<!-- ================================================================== -->
<!-- Target: reports -->
<!-- ================================================================== -->
<target name="report" depends="checkstyle,pmd,classycle,javadoc" description="complete reports">
</target>
<!-- ================================================================== -->
<!-- Target: build -->
<!-- ================================================================== -->
<target name="build" depends="test" description="complete build">
</target>
<!-- ****************************************************************** -->
<!-- * MACROS -->
<!-- ****************************************************************** -->
<!-- ================================================================== -->
<!-- Macro: test.report -->
<!-- ================================================================== -->
<macrodef name="test.report">
<sequential>
<junitreport todir="${test}">
<fileset dir="${test}">
<include name="TEST-*.xml" />
</fileset>
<report format="noframes" todir="${test}">
<param name="TITLE" expression="Test Results" />
</report>
</junitreport>
</sequential>
</macrodef>
<!-- ================================================================== -->
<!-- Macro: coverage.report -->
<!-- ================================================================== -->
<macrodef name="coverage.report">
<sequential>
<jacoco:report>
<executiondata>
<file file="${coverage.data}" />
</executiondata>
<structure name="${distname}">
<classfiles>
<fileset dir="${classes}" />
</classfiles>
<sourcefiles encoding="${proj.encoding}">
<fileset dir="${src.main.java}" />
</sourcefiles>
</structure>
<html destdir="${coverage}" footer="HSLU - Modul ${proj.modul}" />
<xml destfile="${coverage}/coverage.xml" />
</jacoco:report>
<qsreporter jacocoxml="${coverage}/coverage.xml" />
</sequential>
</macrodef>
</project>