forked from GVogeler/mom-ca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·855 lines (761 loc) · 38 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
<?xml version="1.0"?>
<!-- @author: Jochen Graf -->
<project name="XRX" default="install" basedir=".">
<xmlproperty file="build.properties.xml" semanticAttributes="true" keepRoot="true" includeSemanticAttribute="true"/>
<!-- #######################
# Properties #
####################### -->
<!-- from build.properties.xml -->
<property name="admin-name" value="admin"/>
<property name="admin-password" value="${XRX.password}"/>
<property name="deploy-src" value="${XRX.deploy}"/>
<property name="exist-backup-cron-trigger" value="${XRX.exist.backup-cron-trigger}"/>
<property name="exist-cache-size" value="${XRX.exist.cache-size}"/>
<property name="exist-collection-cache" value="${XRX.exist.collection-cache}"/>
<property name="exist-lucene-buffer" value="${XRX.exist.lucene-buffer}"/>
<property name="java-memory-init" value="${XRX.java.initmemory}"/>
<property name="java-memory-max" value="${XRX.java.maxmemory}"/>
<property name="jetty-port" value="${XRX.jetty.port}"/>
<property name="jetty-port-ssl" value="${XRX.jetty.port-ssl}"/>
<property name="project-name" value="${XRX.project-name}"/>
<!-- Tool urls -->
<property name="download-url-betterform" value="https://github.com/icaruseu/betterFORM.git"/>
<property name="download-url-codemirror" value="https://github.com/codemirror/CodeMirror/archive/v2.zip"/>
<property name="download-url-exist" value="https://github.com/eXist-db/exist/archive/eXist-4.7.0.zip"/>
<property name="download-url-jquery" value="https://github.com/jquery/jquery-ui/archive/1-9-stable.zip"/>
<property name="download-url-leaflet" value="https://github.com/Leaflet/Leaflet/archive/v1.3.4.zip"/>
<property name="download-url-leaflet-markercluster" value="https://github.com/Leaflet/Leaflet.markercluster/archive/v1.4.1.zip"/>
<property name="download-url-jssaxparser" value="https://codeload.github.com/ndebeiss/jsXmlSaxParser/zip/master"/>
<!-- System -->
<property name="build-scripts-home" value="build"/>
<property name="data-home" value="../${project-name}.XRX-data"/>
<property name="tmp-home" value="tmp"/>
<!-- XRX -->
<property name="db-uri" value="xmldb:exist://localhost:${jetty-port}"/>
<property name="exist-build-workaround-webapp" value="webapp"/>
<property name="my-xrx-res" value="my/XRX/res"/>
<property name="my-xrx-src" value="my/XRX/src"/>
<property name="my-xrx-system" value="my/XRX/system"/>
<property name="xrx-live-collection-name" value="XRX.live"/>
<property name="xrx-res-collection-name" value="XRX.res"/>
<property name="xrx-src-collection-name" value="XRX.src"/>
<property name="xmldb-xmlrpc-uri" value="${db-uri}/xmlrpc"/>
<property name="xmldb-root-uri" value="${xmldb-xmlrpc-uri}/db"/>
<property name="xmldb-xrx-live-uri" value="${xmldb-root-uri}/${xrx-live-collection-name}"/>
<property name="xmldb-xrx-res-uri" value="${xmldb-root-uri}/${xrx-res-collection-name}"/>
<property name="xmldb-xrx-src-uri" value="${xmldb-root-uri}/${xrx-src-collection-name}"/>
<property name="xmldb-xrx-system-uri" value="${xmldb-root-uri}/system"/>
<property name="xrx-compiler-tmp-file" value=".XRX.compiler.tmp"/>
<property name="xrx-live-db-base-collection-path" value="xmldb:exist:///db/${xrx-live-collection-name}"/>
<!-- betterFORM -->
<property name="betterform-home" value="betterFORM"/>
<property name="my-betterform-src" value="my/betterFORM"/>
<property name="betterform-debug-allowed" value="false"/>
<!-- CodeMirror -->
<property name="codemirror-home" value="CodeMirror"/>
<property name="my-codemirror-src" value="${my-xrx-res}/codemirror"/>
<!-- jssaxparser -->
<property name="jssaxparser-home" value="jssaxparser"/>
<property name="my-jssaxparser-src" value="${my-xrx-res}/jssaxparser"/>
<!-- jQuery -->
<property name="jquery-home" value="jQuery"/>
<property name="my-jquery-src" value="${my-xrx-res}/jquery"/>
<!-- leaflet -->
<property name="leaflet-home" value="leaflet"/>
<property name="my-leaflet-src" value="${my-xrx-res}/leaflet"/>
<!-- eXist -->
<property name="exist-home" value="localhost"/>
<property name="keystore-alias" value="exist"/>
<property name="keystore-file" value="${exist-home}/key.store"/>
<property name="keystore-password" value="secret"/>
<property name="my-exist" value="my/eXist"/>
<property name="my-exist-core" value="${my-exist}/exist-core"/>
<property name="my-exist-extensions-src" value="${my-exist}/extensions/modules"/>
<property name="my-exist-lib" value="${my-exist}/lib"/>
<property name="my-exist-jetty" value="${my-exist}/tools/jetty"/>
<property name="my-exist-src" value="${my-exist}/src"/>
<property name="my-exist-webapp" value="${my-exist}/webapp"/>
<property name="webinf-home" value="${exist-home}/webapp/WEB-INF"/>
<!-- Jetty -->
<property name="jetty-home" value="${exist-home}/tools/jetty"/>
<!-- YAJSW -->
<property name="wrapper-home" value="${exist-home}/tools/yajsw"/>
<!-- #######################
# Macro definitions #
####################### -->
<macrodef name="log">
<attribute name="message"/>
<sequential>
<echo message="-------------------------"/>
<echo message="@{message}"/>
<echo message="-------------------------"/>
</sequential>
</macrodef>
<macrodef name="download">
<attribute name="src"/>
<attribute name="destdir"/>
<attribute name="destname"/>
<sequential>
<mkdir dir="@{destdir}"/>
<exec executable="wget">
<arg line="-O @{destdir}/@{destname} @{src}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="exist-remove">
<attribute name="uri"/>
<attribute name="collection"/>
<attribute name="user" default="${admin-name}"/>
<attribute name="password" default="${admin-password}"/>
<sequential>
<xdb:remove xmlns:xdb="http://exist-db.org/ant" uri="@{uri}" collection="@{collection}" user="@{user}" password="@{password}"/>
</sequential>
</macrodef>
<macrodef name="exist-store">
<attribute name="uri"/>
<attribute name="user" default="${admin-name}"/>
<attribute name="password" default="${admin-password}"/>
<attribute name="permissions" default="rwxr-xr-x"/>
<attribute name="createcollection" default="true"/>
<attribute name="createsubcollections" default="true"/>
<element name="content" implicit="yes"/>
<sequential>
<xdb:store xmlns:xdb="http://exist-db.org/ant" uri="@{uri}" createcollection="@{createcollection}" createsubcollections="@{createsubcollections}" user="@{user}" password="@{password}" permissions="@{permissions}">
<content/>
</xdb:store>
</sequential>
</macrodef>
<macrodef name="exist-query">
<attribute name="user" default="${admin-name}"/>
<attribute name="password" default="${admin-password}"/>
<attribute name="failonerror" default="true"/>
<attribute name="outputproperty" default=""/>
<element name="params" optional="true"/>
<text name="query"/>
<sequential>
<xdb:xquery xmlns:xdb="http://exist-db.org/ant" uri="${xmldb-root-uri}" user="@{user}" password="@{password}" failonerror="${failonerror}" outputproperty="@{outputproperty}">
<params/>
@{query}
</xdb:xquery>
</sequential>
</macrodef>
<macrodef name="exist-create">
<attribute name="uri"/>
<attribute name="collection"/>
<attribute name="user" default="${admin-name}"/>
<attribute name="password" default="${admin-password}"/>
<sequential>
<xdb:create xmlns:xdb="http://exist-db.org/ant" uri="@{uri}" collection="@{collection}" user="@{user}" password="@{password}"/>
</sequential>
</macrodef>
<macrodef name="exist-addgroup">
<attribute name="name"/>
<sequential>
<xdb:addgroup xmlns:xdb="http://exist-db.org/ant" uri="${xmldb-root-uri}" user="${admin-name}" password="${admin-password}" name="@{name}"/>
</sequential>
</macrodef>
<macrodef name="exist-restore">
<attribute name="backup"/>
<sequential>
<xdb:restore xmlns:xdb="http://exist-db.org/ant" uri="${xmlrpc-uri}" file="@{backup}" user="${admin-name}" password="${admin-password}"/>
</sequential>
</macrodef>
<!-- #######################
# Path declarations #
####################### -->
<path id="classpath-exist-core">
<fileset dir="${exist-home}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${exist-home}/extensions">
<include name="**/lib/*.jar"/>
</fileset>
<fileset dir="${exist-home}/tools/ant/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${exist-home}/exist.jar"/>
<pathelement path="${exist-home}/exist-optional.jar"/>
<pathelement path="${exist-home}/start.jar"/>
</path>
<path id="classpath-exist-jetty">
<fileset dir="${jetty-home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<!-- #######################
# Tasks #
####################### -->
<target name="test">
<log message="Preparing tests....[in progress]"/>
</target>
<target name="exist-classpath">
<typedef resource="org/exist/ant/antlib.xml" uri="http://exist-db.org/ant">
<classpath refid="classpath-exist-core"/>
</typedef>
</target>
<target name="print-properties">
<log message="Printing all properties"/>
<echoproperties/>
</target>
<target name="start" description="Starts the XRX Application Server">
<log message="Starting XRX Application Server"/>
<exec executable="${wrapper-home}/bin/startDaemonNoPriv.sh"/>
</target>
<target name="sleep-until-started">
<log message="Waiting for eXist to start"/>
<waitfor maxwait="3" maxwaitunit="minute" checkevery="250">
<and>
<socket server="localhost" port="${jetty-port}"/>
</and>
</waitfor>
</target>
<target name="stop" description="Stops the XRX Application Server">
<log message="Stopping XRX Application Server"/>
<exec executable="${wrapper-home}/bin/stopDaemonNoPriv.sh"/>
</target>
<target name="restart" description="Restarts the XRX Application Server">
<log message="Restarting XRX Application Server"/>
<exec executable="${wrapper-home}/bin/stopDaemon.sh">
<arg value="stop"/>
</exec>
<exec executable="${wrapper-home}/bin/startDaemon.sh">
<arg value="start"/>
</exec>
</target>
<target name="install" description="Installs the XRX Application Server">
<log message="Installing XRX Application Server"/>
<mkdir dir="${tmp-home}"/>
<antcall target="prepare-tools"/>
<antcall target="prepare-app"/>
<antcall target="install-daemon"/>
<antcall target="restart"/>
<antcall target="sleep-until-started"/>
<antcall target="set-admin-password"/>
<antcall target="clean-xrx"/>
<antcall target="initialize-index-configuration" />
<antcall target="deploy-tools"/>
<antcall target="compile-xrx-project"/>
<antcall target="stop"/>
<antcall target="disable-betterform-debug"/>
<antcall target="clean-up"/>
</target>
<target name="prepare-tools">
<log message="Preparing the tools (eXist, betterFORM etc.)"/>
<antcall target="download-tools"/>
<antcall target="patch-tools"/>
<antcall target="build-tools"/>
</target>
<target name="download-tools">
<log message="Downloading the tools"/>
<antcall target="download-exist"/>
<antcall target="download-jsxmlsaxparser"/>
<antcall target="download-jquery"/>
<antcall target="download-leaflet"/>
<antcall target="download-codemirror"/>
<antcall target="download-betterform"/>
</target>
<target name="download-exist">
<log message="Downloading eXist"/>
<delete dir="${exist-home}" failonerror="false"/>
<download src="${download-url-exist}" destdir="${tmp-home}" destname="exist.zip"/>
<unzip src="${tmp-home}/exist.zip" dest="${exist-home}">
<patternset>
<include name="**/*/**"/>
</patternset>
<regexpmapper from="^exist-[A-Za-z0-9\-\_\.]*/(.*)$" to="\1"/>
</unzip> <!--
<exec executable="git">
<arg line=" clone http://github.com/eXist-db/exist/ -b develop -single-branch localhost "/>
</exec>
<exec executable="git" dir="./localhost">
<arg line=" checkout bf5fc14719a7c"/>
</exec> -->
<chmod perm="+x">
<fileset dir="${exist-home}">
<include name="**/*.sh"/>
</fileset>
</chmod>
</target>
<target name="download-jsxmlsaxparser">
<log message="Downloading jsXmlSaxParser"/>
<delete dir="jssaxparser" failonerror="false"/>
<download src="${download-url-jssaxparser}" destdir="${tmp-home}" destname="jssaxparser.zip"/>
<unzip src="${tmp-home}/jssaxparser.zip" dest="${jssaxparser-home}">
<patternset>
<include name="**/jssaxparser/**"/>
</patternset>
<regexpmapper from="^.*/jssaxparser/(.*)$" to="\1"/>
</unzip>
</target>
<target name="download-jquery">
<log message="Downloading jQuery"/>
<delete dir="${jquery-home}" failonerror="false"/>
<download src="${download-url-jquery}" destdir="${tmp-home}" destname="jQuery.zip"/>
<unzip src="${tmp-home}/jQuery.zip" dest="${jquery-home}">
<patternset>
<include name="**/jquery-ui*/**"/>
</patternset>
<regexpmapper from="^jquery-ui[A-Za-z0-9\-\_\.]*/(.*)$" to="\1"/>
</unzip>
</target>
<target name="download-leaflet">
<log message="Downloading Leaflet"/>
<delete dir="${leaflet-home}" failonerror="false"/>
<download src="${download-url-leaflet}" destdir="${tmp-home}" destname="Leaflet.zip"/>
<download src="${download-url-leaflet-markercluster}" destdir="${tmp-home}" destname="Leaflet-markercluster.zip"/>
<unzip src="${tmp-home}/Leaflet.zip" dest="${leaflet-home}">
<patternset>
<include name="**/Leaflet*/dist/**"/>
</patternset>
<regexpmapper from="^Leaflet[A-Za-z0-9\-\_\.]*/dist/(.*)$" to="\1"/>
</unzip>
<unzip src="${tmp-home}/Leaflet-markercluster.zip" dest="${leaflet-home}">
<patternset>
<include name="**/Leaflet*/dist/**"/>
</patternset>
<regexpmapper from="^Leaflet[A-Za-z0-9\-\_\.]*/dist/(.*)$" to="\1"/>
</unzip>
</target>
<target name="download-codemirror">
<log message="Downloading CodeMirror"/>
<delete dir="${codemirror-home}" failonerror="false"/>
<download src="${download-url-codemirror}" destdir="${tmp-home}" destname="CodeMirror.zip"/>
<unzip src="${tmp-home}/CodeMirror.zip" dest="${codemirror-home}">
<patternset>
<include name="**/CodeMirror-2/**"/>
</patternset>
<regexpmapper from="^CodeMirror-2/(.*)$" to="\1"/>
</unzip>
</target>
<target name="download-betterform">
<log message="Downloading betterFORM"/>
<delete dir="${betterform-home}" failonerror="false"/>
<exec executable="git">
<arg line="clone ${download-url-betterform} ${betterform-home} -b development --single-branch --depth 1"/>
</exec>
</target>
<target name="patch-tools">
<log message="Patching the tools"/>
<antcall target="patch-jssaxparser"/>
<antcall target="patch-jquery"/>
<antcall target="patch-leaflet"/>
<antcall target="patch-codemirror"/>
<antcall target="patch-betterform"/>
<antcall target="patch-exist"/>
</target>
<target name="patch-jssaxparser">
<log message="Patching jsXmlSaxParser"/>
<copy todir="${jssaxparser-home}" overwrite="true">
<fileset dir="${my-jssaxparser-src}"/>
</copy>
</target>
<target name="patch-jquery">
<log message="Patching jQuery"/>
<copy todir="${jquery-home}" overwrite="true">
<fileset dir="${my-jquery-src}"/>
</copy>
</target>
<target name="patch-leaflet">
<log message="Patching Leaflet"/>
<copy todir="${leaflet-home}" overwrite="true">
<fileset dir="${my-leaflet-src}"/>
</copy>
</target>
<target name="patch-codemirror">
<log message="Patching CodeMirror"/>
<copy todir="${codemirror-home}" overwrite="true">
<fileset dir="${my-codemirror-src}"/>
</copy>
</target>
<target name="patch-betterform">
<log message="Patching betterFORM"/>
<copy file="${betterform-home}/build.properties.xml" tofile="${betterform-home}/build.properties.xml.original"/>
<xslt in="${betterform-home}/build.properties.xml.original" style="${build-scripts-home}/build.properties.xsl" out="${betterform-home}/build.properties.xml">
<param name="exist-absolute-path" expression="${basedir}/${exist-home}"/>
</xslt>
<replace file="${betterform-home}/XRX/build-XRX.xml">
<replacefilter token='file="${betterFORM.extension}/main/lib/betterform.jar" todir="${betterFORM.extension}/backup-libs"' value='file="${betterFORM.extension}/main/lib/betterform-exist-5.1-SNAPSHOT-20160615.jar" todir="${betterFORM.extension}/backup-libs"'/>
</replace>
<copy todir="${betterform-home}" overwrite="true">
<fileset dir="${my-betterform-src}">
<include name="web/**"/>
</fileset>
</copy>
<replace file="${betterform-home}/XRX/build-XRX.xml">
<replacefilter token='file="${betterFORM.extension}/backup-libs/betterform.jar" tofile="${betterFORM.extension}/main/lib/betterform.jar"' value='file="${betterFORM.extension}/backup-libs/betterform-exist-5.1-SNAPSHOT-20160615.jar" tofile="${betterFORM.extension}/main/lib/betterform.jar"'/>
</replace>
</target>
<target name="patch-exist">
<log message="Patching eXist"/>
<!-- The creation of webapp/logo.txt is needed because the tests in the eXist build process fail otherwise;
according to the eXist team the eXist build process is not designed to be included as part of
another build like ours: https://sourceforge.net/p/exist/mailman/message/36189586 -->
<mkdir dir="${exist-build-workaround-webapp}"/>
<mkdir dir="${exist-build-workaround-webapp}/WEB-INF/classes"/>
<touch file="${exist-build-workaround-webapp}/logo.jpg"/>
<copy todir="${exist-home}/extensions/modules" overwrite="true">
<fileset dir="${my-exist-extensions-src}"/>
</copy>
<!-- XQueryURLRewrite.java has to be patched because of rewrite of controller search -->
<copy todir="${exist-home}/exist-core" overwrite="true">
<fileset dir="${my-exist-core}"/>
</copy>
<!-- -->
<copy todir="${exist-home}/lib" overwrite="true">
<fileset dir="${my-exist-lib}"/>
</copy>
<echo message="# build.properties"/>
<copy file="${exist-home}/build.properties" tofile="${exist-home}/build.properties.original"/>
<replace file="${exist-home}/build.properties">
<replacefilter token="autodeploy=dashboard,shared,eXide,monex,usermanager" value="autodeploy=dashboard,shared,eXide,monex,usermanager,xquery-versioning-module"/>
</replace>
<echo message="# extensions/build.properties"/>
<copy file="${exist-home}/extensions/build.properties" tofile="${exist-home}/extensions/build.properties.original"/>
<replace file="${exist-home}/extensions/build.properties">
<replacefilter token="include.module.xslfo = false" value="include.module.xslfo = true"/>
<replacefilter token="include.module.xslfo.url = http://apache.cs.uu.nl/dist/xmlgraphics/fop/binaries/fop-1.1-bin.zip" value="include.module.xslfo.url = https://archive.apache.org/dist/xmlgraphics/fop/binaries/fop-2.1-bin.zip"/>
<replacefilter token="include.module.cache = false" value="include.module.cache = true"/>
<replacefilter token="http://apache.cs.uu.nl/dist/xmlgraphics/fop/binaries/fop-1.1-bin.zip" value="http://apache.cs.uu.nl/xmlgraphics/fop/binaries/fop-2.1-bin.zip"/>
</replace>
<copy todir="${jetty-home}/tmp" overwrite="true">
<fileset dir="${my-exist-jetty}/tmp">
<include name="*.xml"/>
<include name="*.ttf"/>
</fileset>
</copy>
<tstamp>
<format property="time" pattern="yyyy-MM-dd-hh-mm-ss"/>
</tstamp>
<delete file="localhost/extensions/betterform/main/lib/betterform.jar"/>
<copy tofile="localhost/extensions/betterform/main/lib/betterform${time}.jar" file="my/eXist/extensions/betterform/main/lib/betterform.jar" overwrite="true"/>
</target>
<target name="build-tools">
<log message="Building the tools"/>
<antcall target="build-exist"/>
<antcall target="build-betterform"/>
</target>
<target name="build-exist">
<log message="Building eXist"/>
<!-- build exist -->
<exec executable="${exist-home}/build.sh">
<arg line="-f ${exist-home}/build.xml"/>
</exec>
<!-- unsign all exist jars -->
<ant antfile="${exist-home}/build.xml" target="jnlp-unsign-all" useNativeBaseDir="true"/>
<!-- sign all exist jars -->
<ant antfile="${exist-home}/build.xml" target="jnlp-all" useNativeBaseDir="true"/>
</target>
<target name="build-betterform">
<log message="Compiling betterFORM"/>
<ant antfile="build-XRX.xml" dir="${betterform-home}/XRX" target="update-betterFORM-exploded"/>
</target>
<target name="prepare-app">
<log message="Patching and configuring the app before deployment"/>
<antcall target="patch-app"/>
<antcall target="configure-jetty"/>
<antcall target="configure-exist"/>
<antcall target="configure-wrapper"/>
</target>
<target name="patch-app">
<log message="Preparing the webapp for deployment"/>
<copy todir="${exist-home}/webapp" overwrite="true">
<fileset dir="${my-exist-webapp}"/>
</copy>
<mkdir dir="${exist-home}/webapp/upload"/>
<mkdir dir="${data-home}"/>
<mkdir dir="${jetty-home}/tmp"/>
</target>
<target name="configure-jetty">
<log message="Configuring Jetty"/>
<copy file="${jetty-home}/etc/jetty.xml" tofile="${jetty-home}/etc/jetty.xml.original"/>
<xslt in="${jetty-home}/etc/jetty.xml.original" style="${build-scripts-home}/jetty.xsl" out="${jetty-home}/etc/jetty.xml">
</xslt>
<copy file="${jetty-home}/etc/jetty-http.xml" tofile="${jetty-home}/etc/jetty-http.xml.original"/>
<xslt in="${jetty-home}/etc/jetty-http.xml.original" style="${build-scripts-home}/jetty-http.xsl" out="${jetty-home}/etc/jetty-http.xml">
<param name="jetty-port" expression="${jetty-port}"/>
</xslt>
<copy file="${jetty-home}/etc/jetty-ssl.xml" tofile="${jetty-home}/etc/jetty-ssl.xml.original"/>
<xslt in="${jetty-home}/etc/jetty-ssl.xml.original" style="${build-scripts-home}/jetty-ssl.xsl" out="${jetty-home}/etc/jetty-ssl.xml">
<param name="jetty-port-ssl" expression="${jetty-port-ssl}"/>
</xslt>
<copy file="${jetty-home}/webapps/exist-webapp-context.xml" tofile="${jetty-home}/webapps/exist-webapp-context.xml.original"/>
<xslt in="${jetty-home}/webapps/exist-webapp-context.xml.original" style="${build-scripts-home}/jetty-context.xsl" out="${jetty-home}/webapps/exist-webapp-context.xml">
</xslt>
<delete dir="${jetty-home}/webapps/portal"/>
</target>
<target name="configure-exist">
<log message="Configuring eXist"/>
<copy file="${exist-home}/conf.xml" tofile="${exist-home}/conf.xml.original"/>
<xslt in="${exist-home}/conf.xml.original" style="${build-scripts-home}/conf.xsl" out="${exist-home}/conf.xml">
<param name="cache-size" expression="${exist-cache-size}"/>
<param name="collection-cache" expression="${exist-collection-cache}"/>
<param name="lucene-buffer" expression="${exist-lucene-buffer}"/>
<param name="db-files" expression="${data-home}"/>
<param name="backup-cron-trigger" expression="${exist-backup-cron-trigger}"/>
</xslt>
<copy file="${webinf-home}/controller-config.xml" tofile="${webinf-home}/controller-config.xml.original"/>
<xslt in="${webinf-home}/controller-config.xml.original" style="${build-scripts-home}/controller-config.xsl" out="${webinf-home}/controller-config.xml">
<param name="project-name" expression="${project-name}"/>
<param name="xrx-live-db-base-collection-path" expression="${xrx-live-db-base-collection-path}"/>
</xslt>
<copy file="${exist-home}/webapp/controller.xql" tofile="${exist-home}/webapp/controller.xql.original"/>
<echo file="${exist-home}/webapp/controller.xql" append="false">
xquery version '3.0';
if ($exist:path eq '/') then
<dispatch xmlns='http://exist.sourceforge.net/NS/exist'>
<redirect url='${project-name}/home'/>
</dispatch>
else
<dispatch xmlns='http://exist.sourceforge.net/NS/exist'>
<ignore>le
<cache-control cache='no'/>
</ignore>
</dispatch>
</echo>
<copy file="${webinf-home}/web.xml" tofile="${webinf-home}/web.xml.original"/>
<xslt in="${webinf-home}/web.xml.original" style="${build-scripts-home}/web.xsl" out="${webinf-home}/web.xml">
<param name="project-name" expression="${project-name}"/>
</xslt>
</target>
<target name="configure-wrapper">
<log message="Configuring the service wrapper"/>
<copy file="${wrapper-home}/conf/wrapper.conf" tofile="${wrapper-home}/conf/wrapper.conf.original"/>
<replace file="${wrapper-home}/conf/wrapper.conf">
<replacefilter token="wrapper.java.initmemory=512" value="wrapper.java.initmemory=${java-memory-init}"/>
<replacefilter token="wrapper.java.maxmemory=2048" value="wrapper.java.maxmemory=${java-memory-max}"/>
<replacefilter token="wrapper.ping.timeout=120" value="wrapper.ping.timeout=600"/>
</replace>
<echo file="${wrapper-home}/conf/wrapper.conf" append="true"> wrapper.java.additional.6=-Djava.io.tmpdir=../../../tools/jetty/tmp
</echo>
</target>
<target name="install-daemon">
<log message="Installing the eXist daemon"/>
<exec executable="${wrapper-home}/bin/installDaemon.sh"/>
</target>
<target name="uninstall-daemon">
<log message="Removing the eXist daemon"/>
<exec executable="${wrapper-home}/bin/uninstallDaemon.sh"/>
</target>
<target name="set-admin-password" depends="exist-classpath">
<log message="Setting the admin password if it's not already set to the configured value"/>
<exist-query user="guest" password="guest" failonerror="false">
system:as-user('${admin-name}', '', xmldb:change-user('${admin-name}', '${admin-password}', 'dba', '/db'))
</exist-query>
</target>
<target name="clean-xrx" depends="exist-classpath" description="Removes all XRX projects from database">
<log message="Cleaning all XRX Projects"/>
<exist-remove uri="${xmldb-root-uri}" collection="${xrx-live-collection-name}"/>
<sleep seconds="2"/>
<exist-remove uri="${xmldb-root-uri}" collection="${xrx-src-collection-name}"/>
<sleep seconds="2"/>
<echo file="${xrx-compiler-tmp-file}">01/01/1990 00:00:00 AM</echo>
</target>
<target name="deploy-tools">
<log message="Deploying the tools"/>
<antcall target="prepare-xrx-res-collection"/>
<antcall target="deploy-jssaxparser"/>
<antcall target="deploy-jquery"/>
<antcall target="deploy-leaflet"/>
<antcall target="deploy-codemirror"/>
</target>
<target name="prepare-xrx-res-collection" depends="exist-classpath">
<log message="Preparing the XRX resource collection in the database"/>
<exist-create uri="${xmldb-root-uri}" collection="${xrx-res-collection-name}"/>
</target>
<target name="deploy-jssaxparser" depends="exist-classpath">
<log message="Deploying jsXmlSaxParser"/>
<exist-remove uri="${xmldb-xrx-res-uri}" collection="jssaxparser"/>
<sleep seconds="2"/>
<exist-store uri="${xmldb-xrx-res-uri}/jssaxparser">
<fileset dir="${jssaxparser-home}"/>
</exist-store>
</target>
<target name="deploy-jquery" depends="exist-classpath">
<log message="Deploying jQuery"/>
<exist-remove uri="${xmldb-xrx-res-uri}" collection="jquery"/>
<sleep seconds="2"/>
<exist-store uri="${xmldb-xrx-res-uri}/jquery">
<fileset dir="${jquery-home}">
<include name="*.*"/>
<include name="ui/**"/>
<include name="themes/**"/>
<include name="external/**"/>
</fileset>
</exist-store>
</target>
<target name="deploy-leaflet" depends="exist-classpath">
<log message="Deploying Leaflet"/>
<exist-remove uri="${xmldb-xrx-res-uri}" collection="leaflet"/>
<sleep seconds="2"/>
<exist-store uri="${xmldb-xrx-res-uri}/leaflet">
<fileset dir="${leaflet-home}">
<include name="*.xml"/>
<include name="*.js"/>
<include name="*.css"/>
</fileset>
</exist-store>
</target>
<target name="deploy-codemirror" depends="exist-classpath">
<log message="Deploying CodeMirror"/>
<exist-remove uri="${xmldb-xrx-res-uri}" collection="codemirror"/>
<sleep seconds="2"/>
<exist-store uri="${xmldb-xrx-res-uri}/codemirror">
<fileset dir="${codemirror-home}">
<include name="lib/**"/>
<include name="mode/**"/>
<include name="keymap/**"/>
<include name="theme/**"/>
<include name="*.xml"/>
<not>
<filename name="**/*.html"/>
</not>
</fileset>
</exist-store>
</target>
<target name="compile-xrx-project" depends="exist-classpath" description="Compiles your XRX project">
<log message="Compiling the XRX Project"/>
<antcall target="deploy-my-modified-xrx"/>
<antcall target="compile-xrx">
<param name="TARGET" value="compile-xrx-project"/>
<param name="PROJECT_NAME" value="${project-name}"/>
<param name="APP_NAME" value=""/>
</antcall>
</target>
<target name="compile-xrx-app" description="Compiles your XRX project. Usage: ant compile-xrx-app -Dapp={$app}">
<log message="Compiling the XRX App"/>
<antcall target="deploy-my-modified-xrx"/>
<antcall target="compile-xrx">
<param name="TARGET" value="compile-xrx-app"/>
<param name="PROJECT_NAME" value="${project-name}"/>
<param name="APP_NAME" value="${app}"/>
</antcall>
</target>
<target name="deploy-my-modified-xrx" depends="exist-classpath">
<log message="Deploying modified XRX source files"/>
<available property="xrx-compiler-tmp-file-exists" file="${xrx-compiler-tmp-file}"/>
<loadfile property="last-modified" srcFile="${xrx-compiler-tmp-file}"/>
<echo>Last modified: ${last-modified}</echo>
<tstamp>
<format property="current-time" pattern="MM/dd/yyyy hh:mm:ss aa" unit="hour"/>
</tstamp>
<echo file="${xrx-compiler-tmp-file}">${current-time}</echo>
<exist-store uri="${xmldb-xrx-src-uri}">
<fileset dir="${my-xrx-src}" includes="${deploy-src}">
<date datetime="${last-modified}" when="after" checkdirs="true" pattern="MM/dd/yyyy hh:mm:ss aa"/>
</fileset>
</exist-store>
</target>
<target name="compile-xrx" depends="exist-classpath">
<log message="Compiling the XRX in the database"/>
<antcall target="prepare-xrx-compiler"/>
<exist-query outputproperty="compiler">
<params>
<variable name="TARGET" value="${TARGET}"/>
<variable name="PROJECT_NAME" value="${project-name}"/>
<variable name="APP_NAME" value="${APP_NAME}"/>
</params>
system:as-user('${admin-name}', '${admin-password}',
util:eval(xs:anyURI('/db/XRX.src/core/app/xrx/compiler.xql')))
</exist-query>
<exist-store uri="${xmldb-xrx-live-uri}/${project-name}/app/xrx">
<fileset file="xrx.conf.xml"/>
</exist-store>
<echo>${compiler}</echo>
</target>
<target name="prepare-xrx-compiler" depends="exist-classpath">
<log message="Preparing the XRX compiler"/>
<xslt in="build.properties.xml" style="${build-scripts-home}/xrx-project.xsl" out="xrx.conf.xml">
<param name="project-name" expression="${project-name}"/>
<param name="xrx-live-collection-name" expression="${xrx-live-collection-name}"/>
</xslt>
<exist-store uri="${xmldb-xrx-src-uri}/core/app/xrx">
<fileset file="xrx.conf.xml"/>
</exist-store>
<exist-store uri="${xmldb-xrx-src-uri}/core/app/xrx/">
<fileset file="build/compiler.xql"/>
</exist-store>
</target>
<target name="disable-betterform-debug" description="Use parameter -Dbetterform-debug-allowed to set the value to change don't use the default value">
<log message="Disabling the BetterForm debug tools"/>
<copy file="${webinf-home}/betterform-config.xml" tofile="${webinf-home}/betterform-config.xml.original"/>
<xslt in="${webinf-home}/betterform-config.xml.original" style="${build-scripts-home}/betterform-config.xsl" out="${webinf-home}/betterform-config.xml">
<param name="betterform-debug-allowed" expression="${betterform-debug-allowed}"/>
</xslt>
</target>
<target name="clean-up">
<log message="Removing all temporary directories"/>
<delete dir="${tmp-home}"/>
<delete dir="${codemirror-home}"/>
<delete dir="${jquery-home}"/>
<delete dir="${leaflet-home}"/>
<delete dir="${jssaxparser-home}"/>
<delete dir="${betterform-home}"/>
<delete dir="${exist-build-workaround-webapp}"/>
</target>
<target name="initialize-new-database">
<log message="initializing new database"/>
<antcall target="store-project-data"/>
<antcall target="add-group">
<param name="GROUP-NAME" value="atom"/>
</antcall>
<antcall target="add-group-member">
<param name="GROUP-NAME" value="atom"/>
<param name="USERNAME" value="${admin-name}"/>
</antcall>
<antcall target="initialize-index-configuration"/>
</target>
<target name="store-project-data" depends="exist-classpath">
<log message="Storing ${project-name}-data in the database"/>
<exist-store uri="${xmldb-root-uri}/${project-name}-data" permissions="rwxrwxrwx">
<fileset dir="${project-name}-data"/>
</exist-store>
</target>
<target name="add-group" depends="exist-classpath">
<log message="Adding group ${GROUP-NAME}"/>
<exist-addgroup name="${GROUP-NAME}"/>
</target>
<target name="add-group-member" depends="exist-classpath">
<log message="Adding user ${USERNAME} to group ${GROUP-NAME}"/>
<exist-query>
system:as-user('${admin-name}', '${admin-password}', sm:add-group-member('${GROUP-NAME}', '${USERNAME}'))
</exist-query>
</target>
<target name="initialize-index-configuration" depends="exist-classpath">
<log message="Deploying collection.xconf files"/>
<exist-store uri="${xmldb-xrx-system-uri}/config" permissions="rwxrwx---">
<fileset dir="${my-xrx-system}/config"/>
</exist-store>
<log message="Reindexing database"/>
<exist-query>
xmldb:reindex('/db')
</exist-query>
</target>
<target name="restore-backup" depends="exist-classpath" description='Restores a backup. Path either with a parameter or as a commandline argument -Dbackup=path_to_backup'>
<log message="Restoring backup ${backup}"/>
<exec executable="/bin/bash">
<arg line="${exist-home}/bin/backup.sh -u "${admin-name}" -p "${admin-password}" -r "${backup}" -ouri=${xmldb-xmlrpc-uri}"/>
</exec>
<antcall target="initialize-index-configuration"/>
</target>
<target name="restore-last-backup" depends="exist-classpath">
<log message="Restoring the last backup"/>
<antcall target="restart"/>
<!-- get latest backup -->
<last id="last.file">
<sort>
<date xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
<resources>
<fileset dir="${data-home}/export">
<include name="**/*"/>
</fileset>
</resources>
</sort>
</last>
<ant target="sleep-until-started"/>
<log message="Restoring latest backup ${latest.modified}"/>
<antcall target="restore-backup">
<param name="backup" value="${ant.refid:last.file}"/>
</antcall>
<log message="Finished restoring latest backup"/>
</target>
</project>