-
Notifications
You must be signed in to change notification settings - Fork 58
/
build.xml
8599 lines (8599 loc) · 372 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"?>
<project name="AEMDemo" default="default" basedir=".">
<!-- The conf/build-personal.properties file can be created to store your own values without touching the default build.xml file released with new demo machines -->
<property file="conf/build-personal.properties"/>
<property file="conf/validation.properties"/>
<!-- The build.properties file contains the default configuration value -->
<property file="build.properties"/>
<!-- Setting some global properties for this build -->
<property name="dist" location="./dist"/>
<property name="ant" location="./ant"/>
<property name="packages" location="./dist/packages"/>
<property name="hotfixes" location="./dist/hotfixes"/>
<property name="certificates" location="./dist/certificates"/>
<property name="demos" location="./demos"/>
<property name="logs" location="./logs/${demo.build}"/>
<property name="temp" location="./tmp"/>
<property name="validation" location="./logs/validation"/>
<property name="infralogs" location="./logs"/>
<property name="mongodb" location="./mongodb"/>
<property name="mysql" location="./mysql"/>
<property name="ffmpeg" location="./ffmpeg"/>
<property name="solr" location="./solr"/>
<property name="java" location="./java"/>
<property name="james" location="./james"/>
<property name="archives" location="./archives"/>
<property name="bin" location="./bin"/>
<!-- This file requires the ant-contrib-1.0b3.jar file to be in the ant/lib folder -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<description>
This is the AEM Demo Machine. Comprehensive toolkit for running and configuring integrated AEM demos.
</description>
<condition property="isWindows">
<os family="windows"/>
</condition>
<condition property="isUnix">
<os family="unix"/>
</condition>
<condition property="isMac">
<os family="mac"/>
</condition>
<!-- build classpath for Java tools -->
<path id="demo.classpath">
<fileset dir="${java}/libs">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${ant}/lib">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${java}/bin"/>
</path>
<!-- Target for creating a new demo environment out of the demo.addon properties -->
<target name="create">
<antcall target="install"/>
<if>
<equals arg1="${demo.addons.1.packages}" arg2="true" casesensitive="false"/>
<then>
<antcall target="packages"/>
</then>
</if>
<!-- Configure needs to happen after the packages are uploade (e.g. cloud services) -->
<antcall target="configure"/>
<if>
<equals arg1="${demo.addons.2.sites}" arg2="true" casesensitive="false"/>
<then>
<antcall target="sites"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.3.assets}" arg2="true" casesensitive="false"/>
<then>
<antcall target="assets"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.4.communities}" arg2="true" casesensitive="false"/>
<then>
<antcall target="communities"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.5.apps}" arg2="true" casesensitive="false"/>
<then>
<antcall target="apps"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.6.forms}" arg2="true" casesensitive="false"/>
<then>
<antcall target="forms"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.7.commerce}" arg2="true" casesensitive="false"/>
<then>
<antcall target="commerce"/>
</then>
</if>
<if>
<equals arg1="${demo.addons.8.weretail}" arg2="true" casesensitive="false"/>
<then>
<antcall target="weretail"/>
</then>
</if>
</target>
<!-- Target for installing then configuring a new baseline demo -->
<target name="demo">
<antcall target="install"/>
<antcall target="packages"/>
<antcall target="configure"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Communities -->
<target name="demo_communities">
<antcall target="demo"/>
<antcall target="communities"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Forms -->
<target name="demo_forms">
<antcall target="demo"/>
<antcall target="forms"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Sites -->
<target name="demo_sites">
<antcall target="demo"/>
<antcall target="sites"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Commerce -->
<target name="demo_commerce">
<antcall target="demo"/>
<antcall target="commerce"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Assets -->
<target name="demo_assets">
<antcall target="demo"/>
<antcall target="assets"/>
</target>
<!-- Target for installing then configuring a new baseline demo for AEM Apps -->
<target name="demo_apps">
<antcall target="demo"/>
<antcall target="apps"/>
</target>
<!-- Target for installing then configuring EVERYTHING -->
<target name="demo_kitchensink">
<antcall target="demo"/>
<antcall target="communities"/>
<antcall target="sites"/>
<antcall target="apps"/>
<antcall target="assets"/>
<antcall target="forms"/>
</target>
<!-- Target for getting some information about a particular demo environment -->
<target name="details" depends="version, configuration">
<if>
<resourceexists>
<file file="${demos}/${demo.build}/demomachine.properties"/>
</resourceexists>
<then>
<antcall target="demo_settings"/>
</then>
<else>
<echo message="This demo environment is not available. Please rebuild first."/>
</else>
</if>
</target>
<!-- Target for loading the persisted demo machine configuration -->
<target name="configuration">
<if>
<resourceexists>
<file file="${demos}/${demo.build}/demomachine.properties"/>
</resourceexists>
<then>
<property file="${demos}/${demo.build}/demomachine.properties"/>
<if>
<not>
<isset property="demomachine.jvmargs"/>
</not>
<then>
<property name="demomachine.jvmargs" value=""/>
</then>
</if>
<if>
<not>
<isset property="demomachine.jvmdebug"/>
</not>
<then>
<property name="demomachine.jvmdebug" value="${AdobeAEM.jvmdebug}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.authorport"/>
</not>
<then>
<property name="demomachine.authorport" value="${AdobeAEM.authorport}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.clusterport"/>
</not>
<then>
<property name="demomachine.clusterport" value="${AdobeAEM.clusterport}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.publishport"/>
</not>
<then>
<property name="demomachine.publishport" value="${AdobeAEM.publishport}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.farmport"/>
</not>
<then>
<property name="demomachine.farmport" value="${AdobeAEM.farmport}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.dynamicmedia"/>
</not>
<then>
<property name="demomachine.dynamicmedia" value="${demo.dynamicmedia}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.dynamicmedia_scene7"/>
</not>
<then>
<property name="demomachine.dynamicmedia_scene7" value="${demo.dynamicmedia_scene7}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.emailserver"/>
</not>
<then>
<property name="demomachine.emailserver" value="${demo.emailserver}"/>
</then>
</if>
<if>
<not>
<isset property="demomachine.haproxy.install"/>
</not>
<then>
<property name="demomachine.haproxy.install" value="${demo.haproxy.install}"/>
</then>
</if>
</then>
<else>
<property name="demomachine.jar" value="${demo.jar}"/>
<property name="demomachine.srp" value="${demo.srp}"/>
<property name="demomachine.type" value="${demo.type}"/>
<property name="demomachine.store" value="${demo.store}"/>
<property name="demomachine.jvmargs" value="${AdobeAEM.jvmargs}"/>
<property name="demomachine.jvmdebug" value="${AdobeAEM.jvmdebug}"/>
<property name="demomachine.dynamicmedia" value="${demo.dynamicmedia}"/>
<property name="demomachine.dynamicmedia_scene7" value="${demo.dynamicmedia_scene7}"/>
<property name="demomachine.authorport" value="${AdobeAEM.authorport}"/>
<property name="demomachine.clusterport" value="${AdobeAEM.clusterport}"/>
<property name="demomachine.publishport" value="${AdobeAEM.publishport}"/>
<property name="demomachine.farmport" value="${AdobeAEM.farmport}"/>
<property name="demomachine.communities.enablement" value="${demo.communities.enablement}"/>
<property name="demomachine.emailserver" value="${demo.emailserver}"/>
<property name="demomachine.haproxy.install" value="${demo.haproxy.install}"/>
</else>
</if>
<!-- Determines the instances needed as a function of demomachine.type -->
<!-- We need the clustered author instance -->
<condition property="hasCluster">
<or>
<equals arg1="${demomachine.type}" arg2="cluster" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="clustpub" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="all" casesensitive="false"/>
</or>
</condition>
<!-- We need the standard publish instance -->
<condition property="hasPublish">
<or>
<equals arg1="${demomachine.type}" arg2="publish" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="farm" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="clustpub" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="all" casesensitive="false"/>
</or>
</condition>
<!-- We need the farm publish instance -->
<condition property="hasFarm">
<or>
<equals arg1="${demomachine.type}" arg2="farm" casesensitive="false"/>
<equals arg1="${demomachine.type}" arg2="all" casesensitive="false"/>
</or>
</condition>
</target>
<target name="demo_settings">
<echo message="Demo Folder: ${demos}/${demo.build}"/>
<echo message="Demo JAR: ${demomachine.jar}"/>
<echo message="Demo SRP: ${demomachine.srp}"/>
<echo message="Demo Type: ${demomachine.type}"/>
<echo message="Demo Store: ${demomachine.store}"/>
<echo message="Demo Author Port: ${demomachine.authorport}"/>
<echo message="Demo Publish Port: ${demomachine.publishport}"/>
<echo message="Demo Dynamic Media: ${demomachine.dynamicmedia}"/>
<echo message="Demo Dynamic Media S7: ${demomachine.dynamicmedia_scene7}"/>
<echo message="Demo JVM debug: ${demomachine.jvmdebug}"/>
<echo message="Demo JVM args: ${demomachine.jvmargs}"/>
</target>
<!-- Target for installing and starting the default AUTHOR and PUBLISH servers -->
<target name="install">
<antcall target="cleanup"/>
<echo message="Installing the build ${demo.build}..."/>
<antcall target="demomachine_analytics_install"/>
<mkdir dir="${demos}/${demo.build}"/>
<mkdir dir="${logs}"/>
<echo message="Persisting runtime options in demomachine.properties"/>
<propertyfile file="${demos}/${demo.build}/demomachine.properties" comment="Demo Machine Instance">
<entry key="demomachine.jar" value="${demo.jar}"/>
<entry key="demomachine.srp" value="${demo.srp}"/>
<entry key="demomachine.type" value="${demo.type}"/>
<entry key="demomachine.store" value="${demo.store}"/>
<entry key="demomachine.dynamicmedia" value="${demo.dynamicmedia}"/>
<entry key="demomachine.dynamicmedia_scene7" value="${demo.dynamicmedia_scene7}"/>
<entry key="demomachine.authorport" value="${AdobeAEM.authorport}"/>
<entry key="demomachine.clusterport" value="${AdobeAEM.clusterport}"/>
<entry key="demomachine.publishport" value="${AdobeAEM.publishport}"/>
<entry key="demomachine.farmport" value="${AdobeAEM.farmport}"/>
<entry key="demomachine.jvmdebug" value="${AdobeAEM.jvmdebug}"/>
<entry key="demomachine.jvmargs" value="${AdobeAEM.jvmargs}"/>
<entry key="demomachine.emailserver" value="${demo.emailserver}"/>
<entry key="demomachine.haproxy.install" value="${demo.haproxy.install}"/>
<entry key="demomachine.communities.enablement" value="${demo.communities.enablement}"/>
</propertyfile>
<property file="${demos}/${demo.build}/demomachine.properties"/>
<if>
<not>
<resourceexists>
<file file="${demos}/${demo.build}/demobuild.properties"/>
</resourceexists>
</not>
<then>
<echo message="Persisting build options in demobuild.properties"/>
<echoproperties destfile="${demos}/${demo.build}/demobuild.properties"/>
</then>
</if>
<property name="demo.spfile" value="${dist}/bin/${demo.jar}-sp.zip"/>
<echo message="AEM JAR to use: ${demo.jar}.jar"/>
<echo message="AEM SRP to use: ${demomachine.srp}"/>
<echo message="AEM Store to use: ${demomachine.store}"/>
<if>
<contains string="${demomachine.jar}" substring=":"/>
<then>
<antcall target="install_docker"/>
</then>
<else>
<antcall target="install_local"/>
</else>
</if>
</target>
<!-- Is Docker up? -->
<target name="dockerup">
<mkdir dir="${infralogs}/docker"/>
<exec executable="${demo.docker.path}/docker" dir="." output="${infralogs}/docker/list-process.log" spawn="false" failonerror="false">
<arg line="ps"/>
</exec>
<if>
<resourcecontains resource="${infralogs}/docker/list-process.log" substring="daemon"/>
<then>
<fail message="Docker doesn't seem to be running. Please start Docker first!"/>
</then>
</if>
</target>
<!-- For Docker installation -->
<target name="install_docker" depends="dockerup,logs,version,configuration">
<!-- Check if we need a MySQL container -->
<if>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<equals arg1="${demo.communities.enablement}" arg2="true" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- This will initialize the local volume with default config files -->
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/mysql.yml.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/mysql.yml"/>
</antcall>
<antcall target="mysql_start"/>
</then>
</if>
<!-- Check if we need a SOLR container -->
<if>
<or>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- This will initialize the local volume with default config files -->
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/solr.yml.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/solr.yml"/>
</antcall>
<antcall target="solr_start"/>
<antcall target="solr_stop"/>
<copy todir="${demos}/${demo.build}/solr/db/${demo.build}" overwrite="true">
<fileset dir="${demos}/${demo.build}/solr/db/mycore">
<include name="conf/**"/>
<include name="core.properties"/>
</fileset>
</copy>
<copy todir="${demos}/${demo.build}/solr/db/${demo.build}/conf" overwrite="true">
<fileset dir="${dist}/community/solr/solr5">
<include name="*"/>
</fileset>
</copy>
<antcall target="solr_start"/>
</then>
</if>
<!-- Check if we need a Mongo container -->
<if>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
</or>
<then>
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/mongo.yml.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/mongo.yml"/>
</antcall>
<antcall target="mongo_start"/>
</then>
</if>
<!-- Setting up the provisioning model for this image -->
<antcall target="install_docker_instance">
<param name="demo.instance" value="author"/>
<param name="demo.mode" value="author"/>
<param name="demo.port" value="${demomachine.authorport}"/>
<param name="demo.portdebug" value="${AdobeAEM.authorportdebug}"/>
</antcall>
<if>
<equals arg1="${hasCluster}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_docker_instance">
<param name="demo.instance" value="cluster"/>
<param name="demo.mode" value="author"/>
<param name="demo.port" value="${demomachine.clusterport}"/>
<param name="demo.portdebug" value="${AdobeAEM.clusterportdebug}"/>
</antcall>
</then>
</if>
<if>
<equals arg1="${hasPublish}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_docker_instance">
<param name="demo.instance" value="publish"/>
<param name="demo.mode" value="publish"/>
<param name="demo.port" value="${demomachine.publishport}"/>
<param name="demo.portdebug" value="${AdobeAEM.publishportdebug}"/>
</antcall>
</then>
</if>
<if>
<equals arg1="${hasFarm}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_docker_instance">
<param name="demo.instance" value="farm"/>
<param name="demo.mode" value="publish"/>
<param name="demo.port" value="${demomachine.farmport}"/>
<param name="demo.portdebug" value="${AdobeAEM.farmportdebug}"/>
</antcall>
</then>
</if>
<foreach target="docker_build_instance" param="yml.file">
<path id="yml.files">
<fileset dir="${demos}/${demo.build}" casesensitive="yes">
<include name="aem-*.yml"/>
</fileset>
</path>
</foreach>
<!-- Check if we need a HA Proxy container -->
<if>
<equals arg1="${demo.haproxy.install}" arg2="true" casesensitive="false"/>
<then>
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/haproxy.conf.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/haproxy.conf"/>
</antcall>
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/Dockerfile-haproxy.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/Dockerfile-haproxy"/>
</antcall>
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/haproxy.yml.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/haproxy.yml"/>
</antcall>
</then>
</if>
<antcall target="start"/>
</target>
<target name="install_docker_instance">
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/Dockerfile-standalone-${demo.instance}.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/Dockerfile-standalone-${demo.instance}"/>
</antcall>
<antcall target="create_from_template">
<param name="template_srcfile" value="${dist}/docker/yaml/aem-${demo.instance}.yml.template"/>
<param name="template_distfile" value="${demos}/${demo.build}/aem-${demo.instance}.yml"/>
</antcall>
<mkdir dir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher"/>
<!-- Provisioning model -->
<copy todir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher" overwrite="true">
<fileset dir="${dist}/docker/provisioning">
<include name="**/*"/>
</fileset>
</copy>
<property name="provisioning.model" value="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/demo/1.0.0-SNAPSHOT/demo-1.0.0-SNAPSHOT.txt"/>
<!-- Encryption keys -->
<copy file="${dist}/config/all/all/cq-demo-keys-1.0.zip" tofile="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/keys/keys/1.0.0/keys-1.0.0.zip" overwrite="true"/>
<replace file="${provisioning.model}" token="[artifacts]" value="[artifacts]${line.separator}com.adobe.aem.demomachine.keys/keys/1.0.0/zip"/>
<!-- Config files -->
<if>
<and>
<equals arg1="${demo.osgi}" arg2="true" casesensitive="false"/>
<available file="${dist}/config" type="dir"/>
</and>
<then>
<echo file="${provisioning.model}" append="true" message="${line.separator}[configurations]${line.separator}"/>
<foreach target="docker_config_item" param="config">
<path id="standard.config">
<fileset dir="${dist}/config" casesensitive="yes">
<include name="all/all/**/*.config"/>
<include name="all/${demo.instance}/**/*.config"/>
<include name="${demo.packages}/all/**/*.config"/>
<include name="${demo.packages}/${demo.instance}/**/*.config"/>
</fileset>
</path>
</foreach>
</then>
</if>
<!-- Communities files -->
<antcall target="community_instance"/>
<antcall target="mysql_instance"/>
<antcall target="docker_community_scorm"/>
<!-- We.Retail files -->
<if>
<and>
<equals arg1="${demo.weretail.local}" arg2="true" casesensitive="false"/>
<equals arg1="${demo.addons.8.weretail}" arg2="true" casesensitive="false"/>
<resourceexists>
<file file="${dist}/samples/we-retail"/>
</resourceexists>
</and>
<then>
<property name="provisioning.path" value="com/adobe/aem/demomachine/weretail"/>
<foreach target="docker_provisioning_instance" param="package" inheritall="true">
<path id="provisioning.files">
<fileset dir="${dist}/samples/we-retail" casesensitive="yes">
<include name="*.zip"/>
</fileset>
</path>
</foreach>
</then>
</if>
<!-- Docker only files -->
<if>
<equals arg1="${demo.docker.packages}" arg2="true" casesensitive="false"/>
<then>
<property name="provisioning.path" value="com/adobe/aem/demomachine/0dt"/>
<foreach target="docker_provisioning_instance" param="package" inheritall="true">
<path id="provisioning.files">
<fileset dir="${dist}/docker/packages" casesensitive="yes">
<include name="*.zip"/>
<include name="all/*.zip"/>
<include name="${demo.instance}/*.zip"/>
</fileset>
</path>
</foreach>
</then>
</if>
<!-- Creating the .yml files for the prereqs infrastructure -->
<if>
<or>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
</or>
<then>
<!-- Updating the yml files to reference the Mongo container and the associated settings -->
<replace file="${demos}/${demo.build}/aem-${demo.instance}.yml" token="crx3tar" value="crx3tar${line.separator} external_links:${line.separator} - ${demo.build}_momgo${demo.build}_1:mongo"/>
</then>
</if>
<if>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
</or>
<then>
<!-- Updating the yml files to reference the Mongo container and the associated settings -->
<replace file="${demos}/${demo.build}/aem-${demo.instance}.yml" token="global-tar" value="global-mongo,fds${line.separator} - mongodb_uri=mongodb://mongo${demo.build}:${demo.mongo.port}${line.separator} - mongodb_name=aem_${demo.mode}"/>
</then>
</if>
<if>
<or>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- Updating the yml files to reference the SOLR container -->
<replace file="${demos}/${demo.build}/aem-${demo.instance}.yml" token="external_links:" value="external_links:${line.separator} - ${demo.build}_solr${demo.build}_1:solr"/>
</then>
</if>
<if>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<equals arg1="${demo.communities.enablement}" arg2="true" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- Updating the yml files to reference the MySQL container -->
<replace file="${demos}/${demo.build}/aem-${demo.instance}.yml" token="external_links:" value="external_links:${line.separator} - ${demo.build}_mysql${demo.build}_1:mysql"/>
</then>
</if>
</target>
<!-- Adds a package to the provisioning mode for the current instance, out of a standard package -->
<target name="docker_provisioning_instance">
<basename property="provisioning.file" file="${package}" suffix=".zip"/>
<propertyregex property="provisioning.file.name" input="${provisioning.file}" regexp="(.*)-(.*)" select="\1"/>
<propertyregex property="provisioning.file.version" input="${provisioning.file}" regexp="(.*)-(.*)" select="\2"/>
<copy file="${package}" todir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/${provisioning.path}/${provisioning.file.name}/${provisioning.file.version}"/>
<propertyregex property="provisioning.pathwithdots" input="${provisioning.path}" regexp="/" replace="\." global="true"/>
<replace file="${provisioning.model}" token="[artifacts]" value="[artifacts]${line.separator}${provisioning.pathwithdots}/${provisioning.file.name}/${provisioning.file.version}/zip"/>
</target>
<target name="docker_build_instance">
<echo message="Building the Docker container for ${yml.file}..."/>
<basename property="yml.instance" file="${yml.file}"/>
<exec executable="${demo.docker.path}/docker-compose" dir="." output="${logs}/docker-compose-${yml.instance}-build.log" spawn="false" failonerror="false">
<arg line="-f '${demos}/${demo.build}/${yml.instance}' build"/>
</exec>
<!-- Check if the build phase was completed successfully -->
<if>
<resourcecontains resource="${logs}/docker-compose-${yml.instance}-build.log" substring="failed to build"/>
<then>
<fail message="Error when building the docker images - check ${logs}/docker-compose-${yml.instance}-build.log"/>
</then>
<else>
<echo message="Docker image successfully built for ${yml.instance}"/>
</else>
</if>
</target>
<target name="docker_config_item">
<basename property="config.name" file="${config}" suffix=".config"/>
<property name="provisioning.model" value="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/demo/1.0.0-SNAPSHOT/demo-1.0.0-SNAPSHOT.txt"/>
<antcall target="create_from_template">
<param name="template_srcfile" value="${config}"/>
<param name="template_distfile" value="${logs}/${config.name}"/>
</antcall>
<replaceregexp file="${logs}/${config.name}" match="(\r?\n)" flags="g" replace="${line.separator}"/>
<loadfile property="config.data" srcFile="${logs}/${config.name}"/>
<echo file="${provisioning.model}" append="true" message="${config.name}${line.separator}"/>
<echo file="${provisioning.model}" append="true" message="${config.data}"/>
<echo file="${provisioning.model}" append="true" message="${line.separator}${line.separator}"/>
</target>
<!-- For local installation -->
<target name="install_local" depends="logs,configuration">
<!-- Make sure the Mongo databases are wiped out -->
<if>
<and>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
</or>
</and>
<then>
<antcall target="mongo_start"/>
<propertyregex property="mongo.prefix" input="${demo.build}" regexp="-" replace="" global="true" defaultvalue="${demo.build}"/>
<if>
<equals arg1="${demo.mongo.external}" arg2="false" casesensitive="false"/>
<then>
<property name="mongo.exec" value="${mongodb}/bin/mongo"/>
</then>
<else>
<property name="mongo.exec" value="${demo.mongo.path}"/>
</else>
</if>
<exec executable="${mongo.exec}" spawn="true">
<arg line="${mongo.prefix}communities --eval "db.dropDatabase()""/>
</exec>
<exec executable="${mongo.exec}" spawn="true">
<arg line="${mongo.prefix}author --eval "db.dropDatabase()""/>
</exec>
<exec executable="${mongo.exec}" spawn="true">
<arg line="${mongo.prefix}publish --eval "db.dropDatabase()""/>
</exec>
</then>
</if>
<!-- Setup a new collection for SOLR -->
<if>
<or>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- Making sure we configure Solr with a new core for this demo build -->
<if>
<resourceexists>
<file file="${solr}/bin/solr"/>
</resourceexists>
<then>
<delete dir="${solr}/example/solr/${demo.build}"/>
<copy todir="${solr}/example/solr/${demo.build}" overwrite="true">
<fileset dir="${solr}/example/solr/collection1">
<include name="**/*"/>
</fileset>
</copy>
<replace file="${solr}/example/solr/${demo.build}/core.properties" token="collection1" value="${demo.build}"/>
</then>
</if>
</then>
</if>
<if>
<resourceexists>
<file file="${dist}/bin/${demo.jar}.jar"/>
</resourceexists>
<then>
<!-- Always a primary author instance -->
<antcall target="install_local_instance">
<param name="demo.instance" value="author"/>
<param name="demo.mode" value="author"/>
<param name="demo.port" value="${demomachine.authorport}"/>
<param name="demo.portdebug" value="${AdobeAEM.authorportdebug}"/>
</antcall>
<!-- Maybe in a cluster -->
<if>
<equals arg1="${hasCluster}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_local_instance">
<param name="demo.instance" value="cluster"/>
<param name="demo.mode" value="author"/>
<param name="demo.port" value="${demomachine.clusterport}"/>
<param name="demo.portdebug" value="${AdobeAEM.clusterportdebug}"/>
</antcall>
</then>
</if>
<!-- Maybe a first publish instance -->
<if>
<equals arg1="${hasPublish}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_local_instance">
<param name="demo.instance" value="publish"/>
<param name="demo.mode" value="publish"/>
<param name="demo.port" value="${demomachine.publishport}"/>
<param name="demo.portdebug" value="${AdobeAEM.publishportdebug}"/>
</antcall>
</then>
</if>
<!-- Maybe we have a farm -->
<if>
<equals arg1="${hasFarm}" arg2="true" casesensitive="false"/>
<then>
<antcall target="install_local_instance">
<param name="demo.instance" value="farm"/>
<param name="demo.mode" value="publish"/>
<param name="demo.port" value="${demomachine.farmport}"/>
<param name="demo.portdebug" value="${AdobeAEM.farmportdebug}"/>
</antcall>
</then>
</if>
</then>
<else>
<fail message="FATAL: File ${demo.jar}.jar does not exist"/>
</else>
</if>
<antcall target="start"/>
<!-- Installing the ACS tools and commons on Author and Publish only -->
<antcall target="acs_instance">
<param name="port" value="${demomachine.authorport}"/>
</antcall>
<if>
<socket server="${demo.host}" port="${demomachine.publishport}"/>
<then>
<antcall target="acs_instance">
<param name="port" value="${demomachine.publishport}"/>
</antcall>
</then>
</if>
</target>
<!-- Searching and replacing a file from a folder to another one -->
<target name="findandreplace">
<if>
<and>
<available file="${search.sourcefolder}" type="dir"/>
<available file="${search.targetfolder}" type="dir"/>
</and>
<then>
<first id="sourcefile">
<fileset dir="${search.sourcefolder}" includes="**/${search.filename}"/>
</first>
<first id="targetfile">
<fileset dir="${search.targetfolder}" includes="**/${search.filename}"/>
</first>
<copy file="${toString:sourcefile}" tofile="${toString:targetfile}" overwrite="true"/>
</then>
</if>
</target>
<!-- Target for setting permissions on bin folder -->
<target name="permissions">
<chmod dir="${bin}" perm="ugo+rx" includes="*.sh"/>
</target>
<!-- Target for deploying the hotfixes before the first startup -->
<target name="hotfix_package_instance" depends="version,configuration">
<if>
<and>
<equals arg1="${demo.hotfixes}" arg2="true" casesensitive="false"/>
<available file="${dist}/hotfixes" type="dir"/>
</and>
<then>
<echo message="Configuring the ${demo.instance} instance"/>
<foreach target="hotfix_package" param="package">
<path id="hotfix.packages">
<fileset dir="${hotfixes}" casesensitive="yes">
<include name="all/*.zip"/>
<include name="all/*.jar"/>
<include name="${demo.packages}/*.zip"/>
<include name="${demo.packages}/*.jar"/>
</fileset>
</path>
</foreach>
</then>
</if>
</target>
<target name="hotfix_package">
<basename property="hotfixname" file="${package}"/>
<echo message="Adding hotfix package ${hotfixname} to ${demo.instance}"/>
<copy file="${package}" todir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
</target>
<!-- Target to install a new instance -->
<target name="install_local_instance">
<echo message="Installing a new demo instance of type ${demo.mode} named ${demo.instance}..."/>
<mkdir dir="${demos}/${demo.build}/${demo.instance}"/>
<copy file="${dist}/license/license-${demo.license}.properties" tofile="${demos}/${demo.build}/${demo.instance}/license.properties"/>
<copy file="${dist}/bin/${demo.jar}.jar" tofile="${demos}/${demo.build}/${demo.instance}/aem-${demo.mode}-p${demo.port}.jar"/>
<java dir="${demos}/${demo.build}/${demo.instance}" jar="${demos}/${demo.build}/${demo.instance}/aem-${demo.mode}-p${demo.port}.jar" output="${logs}/${demo.port}_${demo.instance}_unpack.txt" jvm="${demo.jvm}" fork="true" spawn="false">
<arg line="-unpack"/>
<jvmarg value="-Djava.awt.headless=true"/>
</java>
<if>
<not>
<resourceexists>
<file file="${demos}/${demo.build}/${demo.instance}/crx-quickstart"/>
</resourceexists>
</not>
<then>
<fail message="Invalid ${demo.jar}.jar file, please double check the file integrity"/>
</then>
</if>
<if>
<and>
<resourceexists>
<file file="${demo.spfile}"/>
</resourceexists>
<equals arg1="${demo.servicepack}" arg2="true" casesensitive="false"/>
</and>
<then>
<echo message="INFO: Installing a service pack for this build"/>
<copy file="${demo.spfile}" tofile="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/sp.zip"/>
</then>
</if>
<!-- If we're not in a cluster, we need to start the instance with a number of packages -->
<if>
<not>
<equals arg1="${demo.instance}" arg2="cluster" casesensitive="false"/>
</not>
<then>
<antcall target="mysql_instance"/>
<antcall target="osgi_instance"/>
<antcall target="hotfix_osgi_instance"/>
<antcall target="hotfix_package_instance"/>
<antcall target="community_instance"/>
<antcall target="email_instance"/>
</then>
</if>
</target>
<!-- Target for running a mysql script -->
<target name="mysql_script" depends="configuration">
<if>
<contains string="${demomachine.jar}" substring=":"/>
<then>
<!-- Copying the SQL script to the running container -->
<basename property="demo.sqlfilename" file="${demo.sqlfile}"/>
<exec executable="${demo.docker.path}/docker" dir="." output="${logs}/docker-copy.log" spawn="false" failonerror="false">
<arg line="cp '${demo.sqlfile}' ${demo.build}_mysql${demo.build}_1:${demo.sqlfilename}"/>
</exec>
<!-- Executing the script withing the container -->
<exec executable="${demo.docker.path}/docker" dir="." output="${logs}/docker-exex-mysql-${demo.sqlfilename}.log" spawn="false" failonerror="false">
<arg line="exec ${demo.build}_mysql${demo.build}_1 /bin/sh -c 'mysql -u root -p${demo.mysql.password} </${demo.sqlfilename}'"/>
</exec>
</then>
<else>
<if>
<and>
<equals arg1="${demo.mysql.external}" arg2="false" casesensitive="false"/>
<resourceexists>
<file file="${mysql}/bin/mysql"/>
</resourceexists>
</and>
<then>
<property name="mysql.exec" value="${mysql}/bin/mysql"/>
</then>
<else>
<property name="mysql.exec" value="${demo.mysql.path}"/>
</else>
</if>
<tstamp>
<format property="time.stamp" pattern="yyyy-MM-dd_HH:mm:ss"/>
</tstamp>
<exec executable="${mysql.exec}" spawn="false" output="${logs}/mysql-${time.stamp}.log">
<arg line="-u ${demo.mysql.user} --host=${demo.mysql.host} --port=${demo.mysql.port} --port=${demo.mysql.port} --password=${demo.mysql.password} -e 'source ${demo.sqlfile}' ${demo.sqldatabase}"/>
</exec>
</else>
</if>
</target>
<!-- Target for configuring mySQL for a particular instance -->
<target name="mysql_instance">
<if>
<!-- Checking if mysql is to be used -->
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<equals arg1="${demo.communities.enablement}" arg2="true" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="dsrp" casesensitive="false"/>
</or>
<then>
<!-- Installing the OSGI driver for MySQL -->
<unzip src="${dist}/rdb/mysql.zip" dest="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
<if>
<contains string="${demomachine.jar}" substring=":"/>
<then>
<if>
<equals arg1="${demo.packages}" arg2="aem65" casesensitive="false"/>
<then>
<copy file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/mysql/9/mysql-connector-java-5.1.46-bin.jar" tofile="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/mysql-connector-java/5.1.46/mysql-connector-java-5.1.46.jar" overwrite="true"/>
<property name="provisioning.model" value="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/demo/1.0.0-SNAPSHOT/demo-1.0.0-SNAPSHOT.txt"/>
<echo file="${provisioning.model}" append="true" message="${line.separator}[artifacts startLevel=9]${line.separator}com.adobe.aem.demomachine/mysql-connector-java/5.1.46/jar${line.separator}"/>
<delete dir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
</then>
<else>
<copy file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/mysql/9/mysql-connector-java-5.1.38-bin.jar" tofile="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar" overwrite="true"/>
<property name="provisioning.model" value="${demos}/${demo.build}/${demo.instance}/crx-quickstart/launcher/cache/com/adobe/aem/demomachine/demo/1.0.0-SNAPSHOT/demo-1.0.0-SNAPSHOT.txt"/>
<echo file="${provisioning.model}" append="true" message="${line.separator}[artifacts startLevel=9]${line.separator}com.adobe.aem.demomachine/mysql-connector-java/5.1.38/jar${line.separator}"/>
<delete dir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
</else>
</if>
</then>
</if>
<!-- Need to reset the schemas if already there -->
<antcall target="mysql_start"/>
<copy file="${dist}/rdb/drop_schemas.sql" tofile="${dist}/rdb/drop_schemas_${demo.build}.sql" overwrite="true"/>
<propertyregex property="mysql.prefix" input="${demo.build}" regexp="-" replace="" global="true" defaultvalue="${demo.build}"/>
<echo message="Dropping the MySQL schemas ${mysql.prefix} for DSRP, SCORM and Reporting..."/>
<replace file="${dist}/rdb/drop_schemas_${demo.build}.sql" token="enablementdb" value="${mysql.prefix}reporting"/>
<replace file="${dist}/rdb/drop_schemas_${demo.build}.sql" token="ScormEngineDB" value="${mysql.prefix}scorm"/>
<replace file="${dist}/rdb/drop_schemas_${demo.build}.sql" token="DSRP" value="${mysql.prefix}dsrp"/>
<replace file="${dist}/rdb/drop_schemas_${demo.build}.sql" token="author" value="${mysql.prefix}author"/>
<replace file="${dist}/rdb/drop_schemas_${demo.build}.sql" token="publish" value="${mysql.prefix}publish"/>
<antcall target="mysql_script">
<param name="demo.sqlfile" value="${dist}/rdb/drop_schemas_${demo.build}.sql"/>
<param name="demo.sqldatabase" value=""/>
</antcall>
<delete file="${dist}/rdb/drop_schemas_${demo.build}.sql"/>
<!-- Creating the Schema and the datasource for RDBMK -->
<if>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<then>
<copy file="${dist}/rdb/mysql.sql" tofile="${dist}/rdb/mysql_${demo.instance}${demo.build}.sql" overwrite="true"/>
<replace file="${dist}/rdb/mysql_${demo.instance}${demo.build}.sql" token="@schema@" value="${mysql.prefix}${demo.instance}"/>
<if>
<resourceexists>
<file file="${mysql.exec}"/>
</resourceexists>
<then>
<antcall target="mysql_script">
<param name="demo.sqlfile" value="${dist}/rdb/mysql_${demo.instance}${demo.build}.sql"/>
<param name="demo.sqldatabase" value=""/>
</antcall>
</then>
</if>
<delete file="${dist}/rdb/mysql_${demo.instance}${demo.build}.sql"/>
<replace file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg" token="@@SCHEMA@@" value="${mysql.prefix}${demo.instance}"/>
<replace file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg" token="@@HOST@@" value="${demo.mysql.host}"/>
<replace file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg" token="@@PORT@@" value="${demo.mysql.port}"/>
<replace file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg" token="@@USER@@" value="${demo.mysql.user}"/>
<replace file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg" token="@@PASSWORD@@" value="${demo.mysql.password}"/>
</then>
<else>
<!-- For the enablement use case alone, we don't need the OAK datasource to be configured -->
<delete file="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install/org.apache.sling.datasource.DataSourceFactory-oak.cfg"/>
</else>
</if>
</then>
</if>
</target>
<!-- Target for starting the default AUTHOR and PUBLISH servers -->