-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
475 lines (451 loc) · 16.9 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
<?xml version="1.0"?>
<project name="CMS Platform" default="build" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<property name="project" value="cms-platform" />
<property name="jdk" value="17" />
<property name="fs" value="${file.separator}"/>
<property name="lf" value="${line.separator}"/>
<property name="javadoc.dir" value="docs" />
<property name="base.dir" value="." />
<property name="src.dir" value="${base.dir}/src/main/java" />
<property name="src.test.dir" value="${base.dir}/src/test/java" />
<property name="lib.dir" value="${base.dir}/lib/build" />
<property name="lib.compile.dir" value="${base.dir}/lib/compile" />
<property name="lib.test.dir" value="${base.dir}/lib/tests" />
<property name="database.dir" value="${base.dir}/src/main/database" />
<property name="resources.dir" value="${base.dir}/src/main/resources" />
<property name="web.dir" value="${base.dir}/src/main/webapp" />
<property name="build.dir" value="${base.dir}/build" />
<property name="target.dir" value="${base.dir}/target" />
<property name="out.dir" value="${base.dir}/out" />
<property name="exploded.dir" value="${out.dir}/exploded/ROOT" />
<property name="exploded.work.dir" value="${out.dir}/exploded-work/ROOT" />
<property name="custom.dir" value="${base.dir}/web-customizations" />
<property name="jee.lib.dir" value="${base.dir}/lib/war" />
<typedef resource="org/apache/catalina/ant/catalina.tasks">
<classpath>
<fileset dir="${base.dir}/lib/war" includes="*.jar"/>
</classpath>
</typedef>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties">
<classpath>
<fileset dir="${base.dir}/lib/style" includes="*.jar"/>
</classpath>
</taskdef>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<fileset dir="${base.dir}/lib/tests" includes="*.jar"/>
</classpath>
</taskdef>
<tstamp prefix="start">
<format property="val" pattern="yyyy-MM-dd h:mm aa" />
</tstamp>
<!-- Version for scripts to use -->
<target name="version">
<echo message="Project: ${ant.project.name}"/>
<loadfile srcfile="${src.dir}/com/simisinc/platform/ApplicationInfo.java" property="version">
<filterchain>
<linecontains>
<contains value="String VERSION ="/>
</linecontains>
<tokenfilter>
<!-- public static final String VERSION = "20200323.10000";-->
<replacestring from="public static final String VERSION = "" to=""/>
<replacestring from="";" to=""/>
<trim />
</tokenfilter>
</filterchain>
</loadfile>
<fail unless="version">The version string could not be detected in ApplicationInfo.java</fail>
<echo message="Version: ${version}"/>
<echo message="Date: ${start.val}" />
</target>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${target.dir}" />
</target>
<!-- Creates build directories -->
<target name="prepare" depends="version">
<mkdir dir="${build.dir}"/>
<mkdir dir="${target.dir}"/>
<tstamp />
<path id="web.classpath">
<fileset dir="${lib.compile.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="test.classpath">
<fileset dir="${lib.test.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
</target>
<target name="build" depends="package">
<echo message="Production .war: ${target.dir}/${project}.war"/>
</target>
<!-- Compiles the source code -->
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" source="${jdk}" target="${jdk}"
destdir="${build.dir}"
debug="on"
debuglevel="lines,vars,source"
deprecation="on"
optimize="on"
includeantruntime="false">
<classpath>
<path refid="web.classpath"/>
</classpath>
</javac>
</target>
<target name="jar" depends="compile">
<jar jarfile="${target.dir}/${project}.jar">
<fileset dir="${build.dir}" />
</jar>
</target>
<target name="package" depends="clean,jar">
<mkdir dir="${target.dir}/${project}"/>
<mkdir dir="${target.dir}/${project}/WEB-INF"/>
<mkdir dir="${target.dir}/${project}/WEB-INF/compiled"/>
<mkdir dir="${target.dir}/${project}/WEB-INF/classes"/>
<mkdir dir="${target.dir}/${project}/WEB-INF/lib"/>
<mkdir dir="${target.dir}/${project}/WEB-INF/jsp"/>
<!-- Project Jar -->
<copy file="${target.dir}/${project}.jar"
todir="${target.dir}/${project}/WEB-INF/lib"
verbose="true"/>
<!-- Dependency Libraries -->
<copy todir="${target.dir}/${project}/WEB-INF/lib" flatten="true" preservelastmodified="true">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<!-- Resources -->
<copy todir="${target.dir}/${project}/WEB-INF">
<fileset dir="${web.dir}/WEB-INF">
<include name="**/*.html"/>
<include name="**/*.xml"/>
<include name="**/*.yml"/>
<include name="**/*.tld"/>
<include name="**/*.mmdb"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<copy todir="${target.dir}/${project}/WEB-INF/classes">
<fileset dir="${resources.dir}">
<include name="**/*.properties"/>
<include name="**/*.sql"/>
<exclude name="jobrunr.properties"/>
<exclude name="jobrunr.production.properties"/>
<exclude name="simplelogger.properties"/>
<exclude name="simplelogger.production.properties"/>
</fileset>
</copy>
<!-- Production setting -->
<copy file="${resources.dir}/jobrunr.production.properties"
tofile="${target.dir}/${project}/WEB-INF/classes/jobrunr.properties"
overwrite="true"
verbose="false"/>
<copy file="${resources.dir}/simplelogger.production.properties"
tofile="${target.dir}/${project}/WEB-INF/classes/simplelogger.properties"
overwrite="true"
verbose="false"/>
<!-- Version string for scripts -->
<echo file="${target.dir}/${project}/WEB-INF/VERSION" append="true">${version}</echo>
<!-- Web -->
<copy todir="${target.dir}/${project}">
<fileset dir="${web.dir}">
<include name="robots.txt"/>
<include name="css/**"/>
<include name="fonts/**"/>
<include name="images/**"/>
<include name="javascript/**"/>
</fileset>
</copy>
<!-- Custom Web App Content (optional) -->
<copy todir="${target.dir}/${project}" preservelastmodified="true" overwrite="true" failonerror="false">
<fileset dir="${custom.dir}/webapp">
<include name="favicon.ico"/>
<include name="css/**"/>
<include name="fonts/**"/>
<include name="images/**"/>
<include name="javascript/**"/>
</fileset>
</copy>
<!-- Prepare the JSPs-->
<copy todir="${target.dir}/${project}/WEB-INF/jsp">
<fileset dir="${web.dir}/WEB-INF/jsp"/>
</copy>
<!-- Convert the JSPs to Classes -->
<jasper validateXml="false"
uriroot="${target.dir}/${project}"
webXmlFragment="${target.dir}/${project}/WEB-INF/generated_web.xml"
addWebXmlMappings="true"
outputDir="${target.dir}/${project}/WEB-INF/src" />
<!-- Compile the JSPs -->
<javac destdir="${target.dir}/${project}/WEB-INF/compiled" source="${jdk}" target="${jdk}"
optimize="on" debug="off"
srcdir="${target.dir}/${project}/WEB-INF/src"
excludes="**/*.smap">
<classpath>
<pathelement location="${target.dir}/${project}/WEB-INF/classes"/>
<fileset dir="${target.dir}/${project}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${jee.lib.dir}"/>
<fileset dir="${jee.lib.dir}">
<include name="*.jar"/>
</fileset>
</classpath>
<include name="**" />
<exclude name="tags/**" />
</javac>
<!-- JAR the JSPs -->
<jar jarfile="${target.dir}/${project}/WEB-INF/lib/${project}-jsp.jar"
basedir="${target.dir}/${project}/WEB-INF/compiled" includes="**/*.class" />
<!-- Cleanup -->
<delete>
<fileset dir="${target.dir}/${project}/WEB-INF/jsp"/>
<fileset dir="${target.dir}/${project}/WEB-INF/src"/>
<fileset dir="${target.dir}/${project}/WEB-INF/compiled"/>
</delete>
<delete includeemptydirs="true">
<fileset dir="${target.dir}/${project}" >
<and>
<size value="0"/>
<type type="dir"/>
</and>
</fileset>
</delete>
<!-- Create .war -->
<war destfile="${target.dir}/${project}.war"
basedir="${target.dir}/${project}"
compress="true"
manifest="${base.dir}/src/main/webapp/META-INF/MANIFEST.MF"
webxml="${base.dir}/src/main/webapp/WEB-INF/web.xml"/>
<!-- Create a checksum -->
<checksum file="${target.dir}/${project}.war" algorithm="SHA-256" fileext=".sha256" pattern="{0} *{1}"/>
<!-- Write out a version file to go with the .war -->
<echo file="${target.dir}/VERSION" message="${version}"/>
</target>
<target name="webapp" depends="compile">
<delete dir="${exploded.work.dir}"/>
<mkdir dir="${exploded.work.dir}"/>
<mkdir dir="${exploded.work.dir}/WEB-INF"/>
<mkdir dir="${exploded.work.dir}/WEB-INF/classes"/>
<mkdir dir="${exploded.work.dir}/WEB-INF/lib"/>
<mkdir dir="${exploded.work.dir}/WEB-INF/jsp"/>
<!-- Project Classes -->
<copy todir="${exploded.work.dir}/WEB-INF/classes" preservelastmodified="true">
<fileset dir="${build.dir}">
<include name="**"/>
</fileset>
</copy>
<!-- Dependency Libraries -->
<copy todir="${exploded.work.dir}/WEB-INF/lib" flatten="true" preservelastmodified="true">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<!-- Resources -->
<copy todir="${exploded.work.dir}/WEB-INF" preservelastmodified="true">
<fileset dir="${web.dir}/WEB-INF">
<include name="**/*.html"/>
<include name="**/*.json"/>
<include name="**/*.xml"/>
<include name="**/*.yaml"/>
<include name="**/*.yml"/>
<include name="**/*.tld"/>
<include name="**/*.mmdb"/>
<include name="**/*.properties"/>
</fileset>
</copy>
<copy todir="${exploded.work.dir}/WEB-INF/classes" preservelastmodified="true">
<fileset dir="${resources.dir}">
<include name="**/*.properties"/>
<include name="**/*.sql"/>
<exclude name="jobrunr.properties"/>
<exclude name="jobrunr.production.properties"/>
<exclude name="simplelogger.properties"/>
<exclude name="simplelogger.production.properties"/>
</fileset>
</copy>
<!-- Developer setting -->
<copy file="${resources.dir}/jobrunr.properties"
tofile="${exploded.work.dir}/WEB-INF/classes/jobrunr.properties"
verbose="false"
preservelastmodified="true"/>
<copy file="${resources.dir}/simplelogger.properties"
tofile="${exploded.work.dir}/WEB-INF/classes/simplelogger.properties"
verbose="false"
preservelastmodified="true"/>
<!-- Web -->
<copy todir="${exploded.work.dir}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="robots.txt"/>
<include name="css/**"/>
<include name="fonts/**"/>
<include name="images/**"/>
<include name="javascript/**"/>
</fileset>
</copy>
<!-- Custom Web App Content (optional) -->
<copy todir="${exploded.work.dir}" preservelastmodified="true" overwrite="true" failonerror="false">
<fileset dir="${custom.dir}/webapp">
<include name="favicon.ico"/>
<include name="css/**"/>
<include name="fonts/**"/>
<include name="images/**"/>
<include name="javascript/**"/>
</fileset>
</copy>
<!-- Prepare the JSPs-->
<copy todir="${exploded.work.dir}/WEB-INF/jsp" preservelastmodified="true">
<fileset dir="${web.dir}/WEB-INF/jsp"/>
</copy>
<!-- Cleanup -->
<!-- <delete verbose="true" includeemptydirs="true">
<fileset dir="${exploded.work.dir}" >
<and>
<size value="0"/>
<type type="dir"/>
</and>
</fileset>
</delete> -->
<echo message=""/>
<!-- Sync with the exploded directory -->
<mkdir dir="${exploded.dir}"/>
<sync todir="${exploded.dir}">
<fileset dir="${exploded.work.dir}">
<include name="**"/>
</fileset>
</sync>
<tstamp prefix="end">
<format property="val" pattern="yyyy-MM-dd h:mm aa" />
</tstamp>
<echo message="Finished: ${end.val}" />
</target>
<target name="checkstyle" depends="prepare">
<mkdir dir="${target.dir}/checkstyle"/>
<checkstyle config="checkstyle.xml"
failureProperty="checkstyle.failure"
failOnViolation="true">
<formatter type="xml" tofile="${target.dir}/checkstyle-result.xml"/>
<fileset dir="${src.dir}" includes="**/*.java"/>
</checkstyle>
</target>
<target name="compile-test" depends="jar">
<javac srcdir="${src.test.dir}" source="${jdk}" target="${jdk}"
destdir="${build.dir}"
debug="off"
deprecation="on"
optimize="on"
includeantruntime="false">
<classpath>
<path refid="web.classpath"/>
<path refid="test.classpath"/>
</classpath>
</javac>
</target>
<target name="ci-test" depends="compile-test">
<junitlauncher haltOnFailure="false" printsummary="true" failureproperty="hasFailingTest">
<classpath refid="web.classpath" />
<classpath refid="test.classpath" />
<classpath>
<pathelement location="${build.dir}"/>
</classpath>
<testclasses>
<fileset dir="${build.dir}">
<include name="**/*Test.class" />
<include name="**/*Tests.class" />
</fileset>
<fork>
<jvmarg value="-Djava.awt.headless=true"/>
</fork>
</testclasses>
</junitlauncher>
<fail if="hasFailingTest" />
</target>
<target name="run-test" depends="compile-test">
<mkdir dir="${target.dir}/test-reports"/>
<jacoco:agent property="jacocoagent" destfile="${target.dir}/jacoco.exec"/>
<junitlauncher haltOnFailure="true" printSummary="true">
<classpath refid="web.classpath" />
<classpath refid="test.classpath" />
<classpath>
<pathelement location="${build.dir}"/>
</classpath>
<testclasses outputdir="${target.dir}/test-reports">
<fileset dir="${build.dir}">
<include name="**/*Test.class" />
<include name="**/*Tests.class" />
</fileset>
<fork>
<jvmarg value="${jacocoagent}"/>
<jvmarg value="-Djava.awt.headless=true"/>
</fork>
</testclasses>
</junitlauncher>
</target>
<target name="test" depends="run-test">
<jacoco:report>
<executiondata>
<file file="${target.dir}/jacoco.exec"/>
</executiondata>
<structure name="CMS Platform">
<classfiles>
<fileset dir="${build.dir}">
<exclude name="**/*Test*.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src/main/java"/>
</sourcefiles>
</structure>
<html destdir="${target.dir}/coverage-reports/jacoco"/>
<xml destfile="${target.dir}/coverage-reports/jacoco/jacoco.xml"/>
</jacoco:report>
<java classpathref="test.classpath" classname="org.junit.platform.console.ConsoleLauncher" fork="true" failonerror="true">
<arg value="--scan-classpath"/>
<arg line="--reports-dir ${target.dir}/test-reports"/>
</java>
<junitreport todir="${target.dir}/test-reports">
<fileset dir="${target.dir}/test-reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${target.dir}/test-reports/html"/>
</junitreport>
</target>
<target name="mvn-tree">
<exec executable="mvn">
<arg value="dependency:tree" />
</exec>
</target>
<target name="mvn-dependencies">
<delete dir="${lib.dir}" />
<exec executable="mvn">
<arg value="dependency:copy-dependencies" />
<arg value="-DincludeScope=compile" />
<arg value="-DexcludeArtifactIds=commons-logging" />
<arg value="-DexcludeGroupIds=org.apache.tomcat,org.projectlombok,org.jetbrains.kotlin,junit" />
<arg value="-DoutputDirectory=${lib.dir}" />
</exec>
</target>
<target name="node-dependencies">
<!-- Make sure packages are downloaded -->
<exec executable="npm">
<arg value="install" />
</exec>
<!-- Copy the packages into the codebase -->
<exec executable="npm">
<arg value="run" />
<arg value="dependencies" />
</exec>
</target>
<target name="snyk">
<exec executable="snyk">
<arg value="test" />
</exec>
</target>
</project>