-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
1301 lines (1209 loc) · 48.2 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
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE ant>
<project
basedir="."
default="war"
name="vocabs-registry"
xmlns:if="ant:if"
xmlns:unless="ant:unless"
xmlns:jacoco="antlib:org.jacoco.ant"
xmlns:liquibase="antlib:liquibase.integration.ant"
>
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<property name="build" value="build" />
<property name="build-jar" value="build-jar" />
<property name="build-liquibase" value="build-liquibase" />
<property name="build-test" value="build-test" />
<property name="build-tools" value="tools/build" />
<!-- Configuration files: toolkit.properties, logback.xml -->
<property name="conf" value="conf" />
<property name="conf-test" value="conf-test" />
<!-- Generated source code -->
<property name="src-db-gen" value="src/db-gen" />
<property name="src-jaxb-gen" value="src/jaxb-gen" />
<property name="src-bot-detection" value="src/CrawlerDetect" />
<property name="src-bot-detection-gen"
value="src/main/java/au/org/ands/vocabs/registry/utils/BotDetector.java" />
<!-- Generated test code/data -->
<property name="src-test-dbunit-registry-dtd"
value="src/test/resources/deploy/test/dbunit-registry-export-choice.dtd" />
<!-- Generated PHP Client API -->
<property name="php-client-dir" value="php-client" />
<!-- Generated JavaScript Client API -->
<property name="js-client-dir" value="js-client" />
<!-- mapstruct -->
<property name="mapstruct-processor"
value="libdev/mapstruct-1.4.2/mapstruct-processor-1.4.2.Final.jar" />
<property name="mapstruct-sources" value="src/mapstruct/java" />
<!-- JAR files that contain a JPA persistence unit. -->
<property name="toolkit-db-model-jar"
value="${build-jar}/toolkit-db-model.jar" />
<property name="registry-db-model-jar"
value="${build-jar}/registry-db-model.jar" />
<property name="roles-db-model-jar"
value="${build-jar}/roles-db-model.jar" />
<property name="jar" value="vocabs-registry.jar" />
<property name="war" value="vocabs-registry.war" />
<property name="javadoc-output" value="doc/javadoc" />
<property name="test-output" value="test-output" />
<!-- JaCoCo -->
<property name="jacoco-agent"
value="libdev/jacoco-0.7.6.201602180812/jacocoagent.jar" />
<property name="jacoco-output" value="jacoco.exec" />
<property name="jacoco-report" value="jacoco-report" />
<property name="tomcat-managed"
value="tomcatmanaged/apache-tomcat-7.0.69/" />
<!-- Task definitions -->
<taskdef
resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="libdev/checkstyle-9.3/checkstyle-9.3-all.jar" />
<taskdef
name="forbiddenapis"
classname="de.thetaphi.forbiddenapis.ant.AntTask"
classpath="libdev/forbidden-apis-2.2/forbiddenapis-2.2.jar" />
<taskdef resource="testngtasks"
classpath="libdev/testng-6.14.3/testng-6.14.3.jar" />
<taskdef
uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml">
<classpath path="libdev/jacoco-0.7.6.201602180812/jacocoant.jar" />
</taskdef>
<taskdef
resource="liquibase/integration/ant/antlib.xml"
uri="antlib:liquibase.integration.ant">
<classpath>
<fileset dir="tools/dist/liquibase-3.5.3">
<include name="**/*.jar"/>
</fileset>
<!-- Include MySQL JDBC driver -->
<fileset dir="lib/mysql-connector-java-5.1.35">
<include name="**/*.jar"/>
</fileset>
<!-- Include H2 JDBC driver -->
<fileset dir="libtest/h2-1.4.191">
<include name="**/*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- JAXB RI classpath, and xjc taskdef -->
<path id="jaxb-ri.classpath">
<fileset dir="tools/dist/jaxb-ri-2.2.11" includes="**/*.jar" />
</path>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath refid="jaxb-ri.classpath" />
</taskdef>
<!-- Cleanup -->
<target name="clean">
<delete dir="${src-db-gen}" />
<delete dir="${src-jaxb-gen}" />
<delete file="${src-bot-detection-gen}" />
<delete dir="${build}" />
<delete dir="${build-jar}" />
<delete dir="${build-test}" />
<delete dir="${build-liquibase}" />
<delete dir="${build-tools}" />
<delete dir="${mapstruct-sources}" />
<delete dir="${build-xjc-private-fields-plugin}" />
<delete file="${xjc-private-fields-plugin-jar}" />
<!-- Delete tools-bin iff it is empty.
Need failonerror="false", otherwise "ant clean"
would not be an idempotent operation: if you run it twice
in succession, it would fail the second time at this point.
-->
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${tools-bin}" excludes="**/*" />
</delete>
<delete file="${jar}" />
<delete file="${war}" />
<delete dir="${javadoc-output}" />
<delete dir="${test-output}" />
<delete file="${jacoco-output}" />
<delete dir="${jacoco-report}" />
<!-- Files created for testing -->
<delete file="${src-test-dbunit-registry-dtd}" />
<!-- Files created by testng-bamboo target -->
<delete file="conf/toolkit-h2-bamboo.properties" />
<delete file="conf/registry-h2-bamboo.properties" />
<delete file="conf/roles-h2-bamboo.properties" />
<!-- Work files and log files within managed Tomcat -->
<delete dir="${tomcat-managed}/conf/Catalina" />
<delete dir="${tomcat-managed}/work/Catalina" />
<!-- Need failonerror="false", otherwise "ant clean"
fails on a fresh checkout. -->
<delete failonerror="false">
<fileset dir="${tomcat-managed}/logs" includes="*"/>
</delete>
<delete dir="${tomcat-managed}/webapps/openrdf-sesame" />
<delete file="swagger.json" />
<delete dir="${php-client-dir}" />
<delete dir="${js-client-dir}" />
</target>
<!-- xjc plugin to make generated fields private -->
<property name="tools-bin"
value="tools/bin" />
<property name="xjc-private-fields-plugin-jar"
value="${tools-bin}/xjc-private-fields-plugin.jar" />
<property name="build-xjc-private-fields-plugin"
value="${build-tools}/build-xjc-plugin" />
<!-- Check if generated plugin JAR is up-to-date. -->
<target name="check-xjc-private-fields-plugin-jar">
<uptodate property="xjc-private-fields-plugin-jar.uptodate"
targetfile="${xjc-private-fields-plugin-jar}">
<srcfiles dir="${build-xjc-private-fields-plugin}">
<include name="au/org/ands/vocabs/registry/schema/utils/*.class" />
</srcfiles>
</uptodate>
</target>
<!-- Build JAR containing plugin for xjc. -->
<target name="xjc-private-fields-plugin-jar"
depends="check-xjc-private-fields-plugin-jar"
unless="xjc-private-fields-plugin-jar.uptodate">
<mkdir dir="${build-xjc-private-fields-plugin}" />
<javac debug="true" debuglevel="${debuglevel}"
destdir="${build-xjc-private-fields-plugin}"
includeantruntime="false" source="${source}" target="${target}">
<src path="tools/src/jaxb-utils/java" />
<classpath refid="jaxb-ri.classpath" />
</javac>
<jar destfile="${xjc-private-fields-plugin-jar}">
<fileset dir="${build-xjc-private-fields-plugin}"
includes="au/org/ands/vocabs/registry/schema/utils/*.class" />
<service type="com.sun.tools.xjc.Plugin"
provider="au.org.ands.vocabs.registry.schema.utils.JaxbPrivateMemberPlugin"/>
</jar>
</target>
<!-- Database code generation -->
<!-- The source, human-edited registry database specification. -->
<property name="registry-database-master-changelog"
value="src/main/db/changelog/registry-master.xml" />
<property name="flattened-registry-database-changelog"
value="${build-liquibase}/flattened-registry.xml" />
<!-- Generated a "flattened" view of the registry database,
i.e., by processing all of the Liquibase changesets,
and getting the final result. This is then used by
target generate-registry-db-entity-dao-source. -->
<liquibase:database
id="flattened-registry-database"
driver="org.h2.Driver"
url="jdbc:h2:./${build-liquibase}/flatregistry;AUTO_SERVER=TRUE"
user="any"
password="any" />
<target name="generate-flattened-registry-db-spec">
<!-- Start with an empty directory -->
<delete dir="${build-liquibase}" />
<liquibase:updateDatabase
databaseref="flattened-registry-database"
changelogfile="${registry-database-master-changelog}">
</liquibase:updateDatabase>
<liquibase:generateChangeLog
databaseref="flattened-registry-database">
<liquibase:xml
outputfile="${flattened-registry-database-changelog}"
encoding="UTF-8" />
</liquibase:generateChangeLog>
</target>
<!-- Check if generated registry DB source code is up-to-date. -->
<target name="check-registry-db-entity-dao-source">
<uptodate property="registry-db-entity-dao-source.uptodate"
targetfile="${src-db-gen}/timestamp">
<srcfiles dir="src/main/db">
<include name="*/*.xml" />
<include name="*/*.xsl" />
</srcfiles>
</uptodate>
</target>
<!-- Generate Registry DB Java source code. Note the
"unless" attribute. -->
<target name="generate-registry-db-entity-dao-source"
depends="check-registry-db-entity-dao-source"
unless="registry-db-entity-dao-source.uptodate">
<!-- First, generate the changeLog XML file. -->
<antcall target="generate-flattened-registry-db-spec" />
<!-- Now, transform it with XSLT. -->
<property name="xslt-stdout"
value="${src-db-gen}/java/xslt-stdout.txt" />
<xslt
style="src/main/db/code-generation/generate-jpa-entities-daos.xsl"
in="${flattened-registry-database-changelog}"
out="${xslt-stdout}"
destdir="${src-db-gen}/java"
>
<!-- Use Saxon, as the stylesheet is XSLT 2.0. -->
<classpath location="tools/dist/SaxonHE9-7-0-14J/saxon9he.jar" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- Fail, if the XSLT generated output on standard output.
All of the output should have gone to the various
generated .java files. -->
<fail message="Unexpected output generated by XSLT.">
<condition>
<length file="${xslt-stdout}"
when="greater"
length="0" />
</condition>
</fail>
<delete file="${xslt-stdout}" />
<touch file="${src-db-gen}/timestamp" />
</target>
<!-- JAXB Code generation -->
<!-- Check if generated JAXB source code is up-to-date. -->
<target name="check-jaxb-source">
<uptodate property="jaxb-source.uptodate"
targetfile="${src-jaxb-gen}/timestamp">
<srcfiles dir="src/main/jaxb">
<include name="**/*.xsd" />
<include name="**/*.xjb" />
</srcfiles>
</uptodate>
</target>
<target name="generate-jaxb-source"
depends="xjc-private-fields-plugin-jar,check-jaxb-source"
unless="jaxb-source.uptodate">
<!-- Common classes: enums -->
<mkdir dir="src/jaxb-gen/java" />
<xjc destdir="src/jaxb-gen/java"
readonly="true"
removeOldOutput="true"
>
<!-- Option -Xpf to use our xjc plugin for private fields,
and classpath element to tell xjc how to find it.
Option -npa to move the namespace property down to
the class level, where Swagger processing can find them.
Unfortunately, swagger-core does not (yet) support
reading package-level annotations.
-->
<classpath location="${xjc-private-fields-plugin-jar}" />
<arg line="-Xpf -npa"/>
<binding dir="src/main/jaxb">
<include name="**/*.xjb"/>
</binding>
<schema dir="src/main/jaxb">
<include name="**/*.xsd"/>
</schema>
<produces dir="src/jaxb-gen/java"
includes="**/*.java" />
</xjc>
<!-- Remove all trailing whitespace from generated files. -->
<replaceregexp match="\s+$" replace="" byline="true">
<fileset dir="src/jaxb-gen/java"
includes="**/*.java" />
</replaceregexp>
<!-- Copy in hand-written package-info.java files, since
we had to suppress the auto-generated ones with the "-npa"
option.
-->
<copy
file="src/main/jaxb/au.org.ands.vocabs.registry.db.internal.package-info.java"
tofile="src/jaxb-gen/java/au/org/ands/vocabs/registry/db/internal/package-info.java" />
<copy
file="src/main/jaxb/au.org.ands.vocabs.registry.schema.vocabulary201701.package-info.java"
tofile="src/jaxb-gen/java/au/org/ands/vocabs/registry/schema/vocabulary201701/package-info.java" />
<touch file="${src-jaxb-gen}/timestamp" />
</target>
<!-- Generation of utility class for bot detection. -->
<!-- Check if generated bot detection source code is up-to-date. -->
<target name="check-bot-detection-source">
<uptodate property="bot-detection-source.uptodate"
targetfile="${src-bot-detection-gen}">
<srcfiles dir="${src-bot-detection}/orig">
<include name="*.php" />
</srcfiles>
</uptodate>
</target>
<!-- Generated bot detection Java source code. Note the
"unless" attribute. -->
<target name="generate-bot-detection-source"
depends="check-bot-detection-source"
unless="bot-detection-source.uptodate">
<exec executable="sh"
output="${src-bot-detection-gen}"
resultproperty="awk-status">
<arg value="${src-bot-detection}/generate-matcher.sh"/>
</exec>
<condition property="awk-succeeded">
<equals arg1="${awk-status}" arg2="0"/>
</condition>
<delete unless:set="awk-succeeded" file="${src-bot-detection-gen}" />
</target>
<!-- Compilation of source code -->
<path id="compile-main.classpath">
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="tomcatlib" includes="**/*.jar" />
</path>
<path id="compile-test.classpath">
<pathelement path="${build}" />
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="libdev" includes="**/*.jar" />
<fileset dir="tomcatlib" includes="**/*.jar" />
</path>
<path id="dev-compile-main.classpath">
<fileset dir="lib" includes="**/*.jar" />
<fileset dir="libdev" includes="**/*.jar" />
<fileset dir="tomcatlib" includes="**/*.jar" />
</path>
<target name="compile-main"
depends="generate-registry-db-entity-dao-source,generate-jaxb-source,generate-bot-detection-source">
<mkdir dir="${build}" />
<mkdir dir="${mapstruct-sources}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="${build}"
includeantruntime="false" source="${source}" target="${target}">
<src path="src/main/java" />
<src path="src/db-gen/java" />
<src path="src/jaxb-gen/java" />
<!-- Don't include test classes. For now, if you want to use
the test classes, use the project in Eclipse.
<src path="src/test/java" />
-->
<classpath refid="compile-main.classpath" />
<!-- Add -parameters for use by Hibernate Validator's
ReflectionParameterNameProvider, which we mention
in validation.xml. -->
<compilerarg line="-parameters" />
<!-- Options for MapStruct. -->
<compilerarg
line="-processorpath ${mapstruct-processor}"/>
<compilerarg line="-s ${mapstruct-sources}"/>
</javac>
</target>
<target name="compile-errorprone">
<delete dir="${build}-errorprone" />
<mkdir dir="${build}-errorprone" />
<javac
debug="true"
debuglevel="${debuglevel}"
destdir="${build}-errorprone"
includeantruntime="false"
source="${source}"
target="${target}"
compiler="com.google.errorprone.ErrorProneAntCompilerAdapter"
>
<src path="src/main/java" />
<src path="src/test/java" />
<classpath refid="compile-test.classpath" />
<compilerclasspath>
<pathelement
location="libdev/error-prone-2.0.13/error_prone_ant-2.0.13.jar"/>
</compilerclasspath>
</javac>
</target>
<target name="compile-test" depends="compile-main">
<mkdir dir="${build-test}" />
<javac debug="true" debuglevel="${debuglevel}"
destdir="${build-test}"
includeantruntime="false" source="${source}" target="${target}">
<src path="src/test/java" />
<classpath refid="compile-test.classpath" />
<!-- Add -parameters for use by Hibernate Validator's
ReflectionParameterNameProvider, which we mention
in validation.xml. -->
<compilerarg line="-parameters" />
</javac>
</target>
<!-- JAR not usable in the WAR, as JPA seems to require both
persistence.xml and entity classes to be at the "top level",
i.e., in WEB-INF/classes.
<target name="jar" depends="compile-main">
<jar destfile="${jar}">
<fileset dir="${build}" />
</jar>
</target>
-->
<!-- JAR files containing persistence units -->
<target name="toolkit-db-model-jar" depends="compile-main">
<jar destfile="${toolkit-db-model-jar}">
<!-- Generated JAR file has META-INF directory first anyway, so it's
neater to include persistence.xml first ... -->
<mappedresources>
<fileset
dir="src/main/java/au/org/ands/vocabs/toolkit/db/model/META-INF"
/>
<globmapper from="*" to="META-INF/*" />
</mappedresources>
<!-- ... and then the class files. -->
<fileset
dir="${build}"
includes ="au/org/ands/vocabs/toolkit/db/model/*.class"
/>
</jar>
</target>
<target name="registry-db-model-jar" depends="compile-main">
<jar destfile="${registry-db-model-jar}">
<!-- Generated JAR file has META-INF directory first anyway, so it's
neater to include persistence.xml first ... -->
<mappedresources>
<fileset
dir="src/main/java/au/org/ands/vocabs/registry/db/entity/META-INF"
/>
<globmapper from="*" to="META-INF/*" />
</mappedresources>
<!-- ... and then the class files. -->
<fileset
dir="${build}"
includes="au/org/ands/vocabs/registry/db/entity/*.class"
/>
<fileset
dir="${build}"
includes="au/org/ands/vocabs/registry/db/context/converter/*.class"
/>
</jar>
</target>
<target name="roles-db-model-jar" depends="compile-main">
<jar destfile="${roles-db-model-jar}">
<!-- Generated JAR file has META-INF directory first anyway, so it's
neater to include persistence.xml first ... -->
<mappedresources>
<fileset
dir="src/main/java/au/org/ands/vocabs/roles/db/entity/META-INF"
/>
<globmapper from="*" to="META-INF/*" />
</mappedresources>
<!-- ... and then the class files. -->
<fileset
dir="${build}"
includes="au/org/ands/vocabs/roles/db/entity/*.class"
/>
<fileset
dir="${build}"
includes="au/org/ands/vocabs/roles/db/context/converter/*.class"
/>
</jar>
</target>
<!-- Deployable objects -->
<target name="war"
depends="compile-main,update-version-string,toolkit-db-model-jar,registry-db-model-jar,roles-db-model-jar">
<war destfile="${war}">
<metainf dir="WebContent/META-INF" />
<webinf dir="WebContent/WEB-INF" />
<!-- Need to use this trick instead of a lib element because
the JAR files are stored in subdirectories.
See http://stackoverflow.com/questions/2802671/how-to-perform-ant-path-mapping-in-a-war-task -->
<mappedresources>
<fileset dir="lib" includes="**/*.jar" />
<chainedmapper>
<flattenmapper />
<globmapper from="*" to="WEB-INF/lib/*" />
</chainedmapper>
</mappedresources>
<lib file="${toolkit-db-model-jar}" />
<lib file="${registry-db-model-jar}" />
<lib file="${roles-db-model-jar}" />
<!-- Include other raw classes. -->
<classes dir="${build}">
<!-- Exclude the classes put into the JARs. -->
<exclude name="au/org/ands/vocabs/toolkit/db/model/*.class" />
<exclude name="au/org/ands/vocabs/registry/db/entity/*.class" />
<exclude name="au/org/ands/vocabs/roles/db/entity/*.class" />
</classes>
<mappedresources>
<fileset dir="${conf}" />
<globmapper from="*" to="WEB-INF/classes/*" />
</mappedresources>
<!-- Include Hibernate Validator properties. -->
<mappedresources>
<fileset dir="src/main/java/META-INF" />
<globmapper from="*" to="WEB-INF/classes/META-INF/*" />
</mappedresources>
</war>
</target>
<!-- Database generation -->
<!-- To use this, specify this on the command line:
-Dregistrydb-properties=path/to/registrydb.properties \
-->
<property
file="${registrydb-properties}"
prefix="registrydb" />
<liquibase:database
id="registry-database"
driver="${registrydb.driver}"
url="${registrydb.url}"
user="${registrydb.username}"
password="${registrydb.password}" />
<target name="registry-database-update">
<liquibase:updateDatabase
databaseref="registry-database"
changelogfile="${registry-database-master-changelog}"/>
</target>
<!-- Configuration management -->
<!-- The following targets are based on:
http://llbit.se/?p=1876 -->
<!-- To do a new release, create and commit a new version of
version.properties.
NB: in next line, remove slash between the two hyphens!
(XML thinks two consecutive hyphens end the comment.)
Call git update-index -/-no-assume-unchanged conf/version.properties
to enable git to do the commit of the file.
Specify -DToolkit.version=XYZ on the ant command line when building
so as to inhibit creating a new version.properties.
(Literally "XYZ" or something else; the value doesn't matter.
This is not specifying a version number; just defining the property
inhibits the update-version-string target.) -->
<!-- this target is only run if the 'version' property is undefined -->
<target name="update-version-string" depends="-timestamp"
unless="Toolkit.version">
<!-- get a new version string using git describe if possible -->
<echo message="Updating version string..." />
<exec executable="git" outputproperty="Toolkit.version"
failifexecutionfails="false">
<arg value="describe" />
</exec>
<antcall target="-store-version-string" />
<!-- ensure version is defined even if git was not available -->
<property file="${conf}/version.properties" />
</target>
<target name="-timestamp">
<tstamp>
<format property="Toolkit.versionTimestamp" timezone="UTC"
pattern="yyyy-MM-dd'T'HH:mm'Z'" />
<format property="Toolkit.buildDate" timezone="UTC"
pattern="yyyy-MM-dd" />
</tstamp>
</target>
<target name="-store-version-string" depends="-timestamp"
if="Toolkit.version">
<!-- store the new version string in the correct property file -->
<echo message="version=${Toolkit.version}" />
<propertyfile file="${conf}/version.properties">
<entry key="Toolkit.version" value="${Toolkit.version}" />
<entry key="Toolkit.versionTimestamp"
value="${Toolkit.versionTimestamp}" />
<entry key="Toolkit.buildDate" value="${Toolkit.buildDate}" />
</propertyfile>
<exec executable="git">
<arg value="update-index" />
<arg value="--assume-unchanged" />
<arg value="${conf}/version.properties" />
</exec>
</target>
<!-- Documentation generation -->
<property name="jdk.javadoc"
value="https://docs.oracle.com/javase/8/docs/api/" />
<property name="jee.javadoc"
value="https://docs.oracle.com/javaee/7/api/" />
<!-- Was: value="https://www.slf4j.org/api/" -->
<property name="slf4j.javadoc"
value="https://www.javadoc.io/doc/org.slf4j/slf4j-api/1.7.25/" />
<property name="pac4j.javadoc"
value="https://www.pac4j.org/apidocs/pac4j/2.0.0/" />
<!-- Was: value="https://archive.rdf4j.org/javadoc/sesame-2.8.3/" -->
<property name="openrdf.javadoc"
value="https://hasmac-as.github.io/archive-sesame/javadoc/sesame-2.8.3/" />
<property name="commons-collections.javadoc"
value="https://commons.apache.org/proper/commons-collections/javadocs/api-4.1/" />
<target name="javadoc">
<!-- Add "-J-Dhttp.agent=javadoc" to the command line to overcome
failure to get pac4j content, because that server rejects
the default user agent "Java/1.8.0_121".
-->
<javadoc sourcepath="src/main/java;src/db-gen/java;src/jaxb-gen/java;src/test/java"
additionalparam="-J-Dhttp.agent=javadoc"
destdir="${javadoc-output}"
classpathref="dev-compile-main.classpath"
linksource="true"
includenosourcepackages="true"
private="true"
failonerror="true"
Overview="src/main/java/overview.html"
>
<group title="Registry database"
packages="au.org.ands.vocabs.registry.db*" />
<group title="Registry API"
packages="au.org.ands.vocabs.registry.api*" />
<group title="Registry schema"
packages="au.org.ands.vocabs.registry.enums:au.org.ands.vocabs.registry.schema*" />
<group title="Vocabulary model subsystems"
packages="au.org.ands.vocabs.registry.model*" />
<group title="Publication workflow subsystem"
packages="au.org.ands.vocabs.registry.workflow*" />
<group title="Subscription and notification subsystem"
packages="au.org.ands.vocabs.registry.notification*:au.org.ands.vocabs.registry.subscription*" />
<group title="Test packages"
packages="au.org.ands.vocabs.registry.test*:au.org.ands.vocabs.toolkit.test*" />
<group title="Roles database"
packages="au.org.ands.vocabs.roles.db*" />
<group title="Legacy Toolkit database"
packages="au.org.ands.vocabs.toolkit.db*" />
<link href="${jdk.javadoc}" />
<link href="${jee.javadoc}" />
<link href="${slf4j.javadoc}" />
<link href="${pac4j.javadoc}" />
<link href="${openrdf.javadoc}" />
<link href="${commons-collections.javadoc}" />
</javadoc>
</target>
<!-- Install the Solr schema. The Collection must already have been
created! -->
<path id="create-solr-schema.classpath">
<pathelement path="${build}" />
<fileset dir="lib">
<include name="**/*.jar" />
<exclude name="javamelody*/*.jar" />
<exclude name="mysql*/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
</fileset>
</path>
<target name="create-solr-schema"
depends="compile-main">
<property file="conf/registry.properties" />
<java
fork="true"
failonerror="true"
classname="au.org.ands.vocabs.registry.solr.admin.CreateSolrSchemaRegistry"
classpathref="create-solr-schema.classpath"
>
<arg value="${Registry.Solr.baseURL}" />
<arg value="${Registry.Solr.collection}" />
<arg value="${Registry.Solr.collectionURL}" />
<arg value="${Registry.Solr.zkHost}" />
</java>
</target>
<target name="create-solr-schema-resources"
depends="compile-main">
<property file="conf/registry.properties" />
<java
fork="true"
failonerror="true"
classname="au.org.ands.vocabs.registry.solr.admin.CreateSolrSchemaResources"
classpathref="create-solr-schema.classpath"
>
<arg value="${Registry.Solr.baseURL}" />
<arg value="${Registry.Solr.resources.collection}" />
<arg value="${Registry.Solr.resources.collectionURL}" />
<arg value="${Registry.Solr.zkHost}" />
</java>
</target>
<!-- Perform migration of existing JsonTree version artefacts
into the new ConceptTree version artefacts! -->
<path id="migrate-jsontree-artefacts.classpath">
<pathelement path="${build}" />
<fileset dir="lib">
<include name="**/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
</fileset>
<fileset dir="build-jar">
<include name="*.jar" />
</fileset>
</path>
<target name="migrate-jsontree-artefacts"
depends="compile-main,registry-db-model-jar">
<java
fork="true"
failonerror="true"
classname="au.org.ands.vocabs.registry.db.utils.migration.MigrateJsonTreesToConceptTrees"
classpathref="migrate-jsontree-artefacts.classpath"
>
<sysproperty key="REGISTRY_PROPS_FILE"
value="conf/registry.properties" />
</java>
</target>
<!-- Perform migration of access point hostnames.
Change the parameters to suit, before running! -->
<path id="migrate-accesspoint-hostname.classpath">
<pathelement path="${build}" />
<fileset dir="lib">
<include name="**/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
</fileset>
<fileset dir="build-jar">
<include name="*.jar" />
</fileset>
</path>
<target name="migrate-accesspoint-hostname"
depends="compile-main,registry-db-model-jar">
<java
fork="true"
failonerror="true"
classname="au.org.ands.vocabs.registry.db.utils.migration.MigrateAccessPointHostname"
classpathref="migrate-accesspoint-hostname.classpath"
>
<!-- NB: DO NOT put localhost:8080 in one of the "before"
values, as the rewriter changes everything to https,
which won't then work! -->
<arg value="vocabs.ands.org.au/repository/openrdf-sesame/"/>
<arg value="vocabs.ardc.edu.au/repository/openrdf-sesame/"/>
<arg value="vocabs.ands.org.au/registry/api/resource/downloads/"/>
<arg value="vocabs.ardc.edu.au/registry/api/resource/downloads/"/>
<arg value="vocabs.ands.org.au/repository/api/sparql"/>
<arg value="vocabs.ardc.edu.au/repository/api/sparql"/>
<arg value="vocabs.ands.org.au/repository/api/lda"/>
<arg value="vocabs.ardc.edu.au/repository/api/lda"/>
<sysproperty key="REGISTRY_PROPS_FILE"
value="conf/registry.properties" />
</java>
</target>
<!-- Coding conventions, style, static analysis -->
<target name="checkstyle"
description="Generates a report of code convention violations."
depends="generate-registry-db-entity-dao-source,generate-jaxb-source,generate-bot-detection-source">
<!-- Be very picky: fail even on a single warning. -->
<checkstyle config="ands-checkstyle.xml"
maxWarnings="0">
<!-- Options that could be added to checkstyle element: -->
<!-- failureProperty="checkstyle.failure" -->
<!-- failOnViolation="false" -->
<!-- classpathref seems not to be needed: -->
<!-- classpathref="compile-main.classpath" -->
<!-- Possible future work: write report to a file: -->
<!-- <formatter type="xml" tofile="checkstyle_report.xml"/> -->
<!-- Define "samedir" property as used in the config. (The
"samedir" property is an Eclipse-CS thing. -->
<property key="samedir" value="." />
<fileset dir="src/main/java" includes="**/*.java"/>
<fileset dir="src/db-gen/java" includes="**/*.java"/>
<fileset dir="src/jaxb-gen/java" includes="**/*.java"/>
<fileset dir="src/test/java" includes="**/*.java"/>
</checkstyle>
<!-- Possible future work: if generating a report, make a pretty
version. -->
<!-- <style in="checkstyle_report.xml"
out="checkstyle_report.html"
style="checkstyle.xsl"/> -->
</target>
<!-- For now, we don't fail the build on failing this!
For a rainy day: come back to this, and remove
as many of the reported violations as possible.
-->
<target name="forbidden-checks" depends="compile-main">
<forbiddenapis
classpathref="compile-main.classpath"
dir="${build}"
targetVersion="${target}">
<bundledsignatures name="jdk-unsafe"/>
<bundledsignatures name="jdk-deprecated"/>
<bundledsignatures name="jdk-internal"/>
<bundledsignatures name="jdk-non-portable"/>
<bundledsignatures name="jdk-system-out"/>
<bundledsignatures name="jdk-reflection"/>
<bundledsignatures name="commons-io-unsafe-2.4"/>
</forbiddenapis>
</target>
<!-- Have a separate target for this, as the "forbiddenapis"
task only allows for one directory of classes to
check, and the task fails on error. So this is the
only way to see the results for test code.
-->
<target name="forbidden-checks-test" depends="compile-test">
<forbiddenapis
classpathref="compile-test.classpath"
dir="${build-test}"
targetVersion="${target}">
<bundledsignatures name="jdk-unsafe"/>
<bundledsignatures name="jdk-deprecated"/>
<bundledsignatures name="jdk-internal"/>
<bundledsignatures name="jdk-non-portable"/>
<bundledsignatures name="jdk-system-out"/>
<bundledsignatures name="jdk-reflection"/>
<bundledsignatures name="commons-io-unsafe-2.4"/>
</forbiddenapis>
</target>
<!-- Support for automated testing: generate DbUnit DTD files. -->
<path id="generate-DTD.classpath">
<pathelement path="${build}" />
<pathelement path="${build-test}" />
<fileset dir="lib">
<include name="**/*.jar" />
<exclude name="javamelody*/*.jar" />
<exclude name="mysql*/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
</fileset>
<fileset dir="libtest">
<include name="**/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
</fileset>
<fileset dir="libdev">
<include name="**/*.jar" />
<exclude name="**/*javadoc*.jar" />
<exclude name="**/*sources*.jar" />
<exclude name="arquillian-notyet/**/*.jar" />
</fileset>
<fileset dir="tomcatlib" includes="**/*.jar" />
<!-- This is the main difference from testng.classpath:
for a standalone app, we need the database model JARs. -->
<pathelement location="${toolkit-db-model-jar}" />
<pathelement location="${registry-db-model-jar}" />
<pathelement location="${roles-db-model-jar}" />
</path>
<!-- Generate the DbUnit DTD for one database.
Note that this used as part of test builds, to generate
the DTD for the registry database, but you have to
call it manually for the roles and toolkit databases,
and commit the results.
Specify two required parameters:
database parameter, with, e.g., -Ddbs=TOOLKIT
output file, with, e.g.,
-Ddtd-output=src/test/resources/deploy/test/dbunit-toolkit-export-choice.dtd
-->
<target name="generate-DTD"
depends="compile-test,toolkit-db-model-jar,registry-db-model-jar,roles-db-model-jar">
<fail unless="dbs" message="No dbs specified" />
<fail unless="dtd-output" message="No dtd-output specified" />
<java
fork="true"
failonerror="true"
output="${dtd-output}"
logError="true"
classname="au.org.ands.vocabs.toolkit.test.arquillian.GenerateDbUnitDTD"
classpathref="generate-DTD.classpath"
>
<jvmarg
value="-DPROPS_FILE=conf/toolkit-h2.properties" />
<jvmarg
value="-DREGISTRY_PROPS_FILE=conf/registry-h2.properties" />
<jvmarg
value="-DROLES_PROPS_FILE=conf/roles-h2.properties" />
<jvmarg
value="-DVERSION_PROPS_FILE=conf/version.properties" />
<arg value="${dbs}" />
</java>
</target>
<!-- Check if generated registry DbUnit DTD is up-to-date. -->
<target name="check-registry-dbunit-DTD">
<uptodate property="registry-dbunit-dtd.uptodate"
targetfile="${src-test-dbunit-registry-dtd}">
<srcfiles dir="src/main/db">
<include name="*/*.xml" />
<include name="*/*.xsl" />
</srcfiles>
</uptodate>
</target>
<!-- Generate Registry DbUnit DTD. Note the
"unless" attribute. -->
<target name="generate-registry-dbunit-dtd"
depends="check-registry-dbunit-DTD"
unless="registry-dbunit-dtd.uptodate">
<antcall target="generate-DTD">
<param name="dbs" value="REGISTRY" />
<param name="dtd-output" value="${src-test-dbunit-registry-dtd}" />
</antcall>
</target>
<!-- Check if generated swagger.json is up-to-date. -->
<target name="check-swagger-json">
<uptodate property="swagger-json.uptodate"
targetfile="swagger.json">
<srcfiles dir="src">
<include name="**/*.java" />
<include name="**/*.xml" />
<include name="**/*.xsl" />
</srcfiles>
<srcfiles dir="build">
<include name="**/*" />
</srcfiles>
<srcfiles dir="build-test">
<include name="**/*" />
</srcfiles>
<srcfiles dir="build-jar">
<include name="*/*.jar" />
</srcfiles>
</uptodate>
</target>
<!-- Generation of swagger.json.
We reuse the core of the testng-bamboo task for this purpose. -->
<target name="swagger-json"
depends="compile-test,toolkit-db-model-jar,registry-db-model-jar,roles-db-model-jar,check-swagger-json"
unless="swagger-json.uptodate">
<copy
file="conf/toolkit-h2-bamboo-template.properties"
tofile="conf/toolkit-h2-bamboo.properties">
<filterset>
<filter
token="bambooBuildWorkingDirectory"
value="${user.dir}" />
</filterset>
</copy>
<copy
file="conf/registry-h2-bamboo-template.properties"
tofile="conf/registry-h2-bamboo.properties">
<filterset>
<filter
token="bambooBuildWorkingDirectory"
value="${bambooBuildWorkingDirectory}" />
</filterset>
</copy>
<copy