forked from Adobe-Marketing-Cloud/aem-demo-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
5216 lines (5216 loc) · 218 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"/>
<!-- 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="demos" location="./demos"/>
<property name="logs" location="./logs/${demo.build}"/>
<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. Comprensive 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>
<if>
<equals arg1="${demo.addons.9.livefyre}" arg2="true" casesensitive="false"/>
<then>
<antcall target="livefyre"/>
</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">
<antcall target="demo_settings"/>
</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.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>
</then>
<else>
<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.authorport" value="${AdobeAEM.authorport}"/>
<property name="demomachine.publishport" value="${AdobeAEM.publishport}"/>
<property name="demomachine.farmport" value="${AdobeAEM.farmport}"/>
<property name="demomachine.communities.enablement" value="${demo.communities.enablement}"/>
</else>
</if>
</target>
<target name="demo_settings">
<echo message="Demo Folder: ${demos}/${demo.build}"/>
<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 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="uninstall"/>
<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.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.authorport" value="${AdobeAEM.authorport}"/>
<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.communities.enablement" value="${demo.communities.enablement}"/>
</propertyfile>
<property file="${demos}/${demo.build}/demomachine.properties"/>
<property name="demo.spfile" value="${dist}/bin/${demo.jar}-sp.zip"/>
<echo message="AEM JAR to use: ${demo.jar}.jar"/>
<if>
<resourceexists>
<file file="${dist}/bin/${demo.jar}.jar"/>
</resourceexists>
<then>
<if>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<then>
<!-- Making sure we configure Solr with a new core for this demo build -->
<antcall target="solr_stop"/>
<if>
<resourceexists>
<file file="${solr}/bin/solr"/>
</resourceexists>
<then>
<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>
<antcall target="install_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>
<not>
<equals arg1="${demomachine.type}" arg2="author" casesensitive="false"/>
</not>
<then>
<antcall target="install_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="${demomachine.type}" arg2="farm" casesensitive="false"/>
<then>
<antcall target="install_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"/>
</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_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">
<copy file="${package}" todir="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
</target>
<!-- Target to install a new instance -->
<target name="install_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" 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>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<equals arg1="${demo.communities.enablement}" arg2="true" casesensitive="false"/>
</or>
<then>
<unzip src="${dist}/rdb/mysql.zip" dest="${demos}/${demo.build}/${demo.instance}/crx-quickstart/install"/>
<if>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
<then>
<antcall target="mysql_start"/>
<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>
<propertyregex property="mysql.prefix" input="${demo.build}" regexp="-" replace="" global="true" defaultvalue="${demo.build}"/>
<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>
<exec executable="${mysql.exec}" spawn="false" failonerror="false">
<arg line="-u ${demo.mysql.user} --host=${demo.mysql.host} --port=${demo.mysql.port} --port=${demo.mysql.port} --password=${demo.mysql.password} -e 'source ${dist}/rdb/mysql_${demo.instance}${demo.build}.sql'"/>
</exec>
</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>
<antcall target="hotfix_instance"/>
<antcall target="community_instance"/>
</target>
<!-- Target for starting the default AUTHOR and PUBLISH servers -->
<target name="start" depends="version,configuration,details">
<echo message="Starting the build for demo ${demo.build}..."/>
<antcall target="prerequisites"/>
<antcall target="javaversion"/>
<antcall target="demomachine_analytics_start"/>
<if>
<equals arg1="${demo.emailserver}" arg2="true" casesensitive="false"/>
<then>
<!-- Making sure we start James SMTP server -->
<antcall target="james_start"/>
</then>
</if>
<if>
<or>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
</or>
<then>
<!-- Making sure we start Mongo with the right data path -->
<antcall target="mongo_start"/>
</then>
</if>
<if>
<equals arg1="${demomachine.srp}" arg2="msrp" casesensitive="false"/>
<then>
<!-- Making sure we start Solr -->
<antcall target="solr_start"/>
</then>
</if>
<if>
<or>
<equals arg1="${demomachine.communities.enablement}" arg2="true" casesensitive="false"/>
<equals arg1="${demomachine.store}" arg2="crx3,crx3rdb" casesensitive="false"/>
</or>
<then>
<!-- Making sure we start MySQL -->
<antcall target="mysql_start"/>
</then>
</if>
<if>
<resourceexists>
<file file="${demos}/${demo.build}/author/aem-author-p${demomachine.authorport}.jar"/>
</resourceexists>
<then>
<echo message="Starting the AUTHOR instance..."/>
<antcall target="aem_start">
<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>
</then>
<else>
<fail message="FATAL: There is no demo build named ${demo.build} to start"/>
</else>
</if>
<if>
<resourceexists>
<file file="${demos}/${demo.build}/publish/aem-publish-p${demomachine.publishport}.jar"/>
</resourceexists>
<then>
<echo message="Starting the PUBLISH instance..."/>
<antcall target="aem_start">
<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>
<echo message="Waiting for the Author instance to be started..."/>
<waitfor maxwait="600" maxwaitunit="second" checkevery="5" checkeveryunit="second">
<and>
<socket server="${demo.host}" port="${demomachine.authorport}"/>
<resourcecontains resource="${demos}/${demo.build}/author/crx-quickstart/logs/stderr.log" substring="Quickstart started"/>
</and>
</waitfor>
<if>
<resourceexists>
<file file="${demos}/${demo.build}/publish/aem-publish-p${demomachine.publishport}.jar"/>
</resourceexists>
<then>
<echo message="Waiting for the Publish instance to be started..."/>
<waitfor maxwait="600" maxwaitunit="second" checkevery="5" checkeveryunit="second">
<and>
<socket server="${demo.host}" port="${demomachine.publishport}"/>
<resourcecontains resource="${demos}/${demo.build}/publish/crx-quickstart/logs/stderr.log" substring="Quickstart started"/>
</and>
</waitfor>
</then>
</if>
<if>
<resourceexists>
<file file="${demos}/${demo.build}/farm/aem-publish-p${demomachine.farmport}.jar"/>
</resourceexists>
<then>
<echo message="Starting the FARM instance..."/>
<antcall target="aem_start">
<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>
<echo message="Waiting for the Farm instance to be started..."/>
<waitfor maxwait="600" maxwaitunit="second" checkevery="5" checkeveryunit="second">
<and>
<socket server="${demo.host}" port="${demomachine.farmport}"/>
<resourcecontains resource="${demos}/${demo.build}/farm/crx-quickstart/logs/stderr.log" substring="Quickstart started"/>
</and>
</waitfor>
<antcall target="configure_farm"/>
</then>
</if>
</target>
<!-- Target for restarting the default AUTHOR and PUBLISH servers -->
<target name="restart">
<echo message="Restarting all running instances"/>
<antcall target="stop"/>
<antcall target="start"/>
</target>
<!-- Target for stopping all running servers -->
<target name="stop">
<echo message="Stopping all running demo instances"/>
<antcall target="demomachine_analytics_stop"/>
<antcall target="stop_unix"/>
<antcall target="stop_windows"/>
</target>
<target name="stop_unix" if="isUnix" depends="permissions">
<exec executable="${bin}/kill.sh" dir="${bin}" spawn="false">
<arg line="'${demos}'"/>
</exec>
<sleep seconds="2"/>
</target>
<target name="stop_windows" if="isWindows">
<exec executable="taskkill.exe" spawn="true">
<arg line="/F /FI "WINDOWTITLE eq Adobe Experience Manager*""/>
</exec>
<sleep seconds="4"/>
</target>
<!-- Target for starting an AEM server -->
<target name="aem_start">
<!-- Making sure the port is not already in use -->
<if>
<socket server="${demo.host}" port="${demo.port}"/>
<then>
<fail message="The port ${demo.port} is already in use."/>
</then>
</if>
<!-- Compute the JVM debug settings when necessary -->
<if>
<equals arg1="${demomachine.jvmdebug}" arg2="true" casesensitive="false"/>
<then>
<property name="jvmdebug" value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${demo.portdebug}"/>
<echo message="Setting JVM debug settings on port ${debug.portdebug}"/>
</then>
<else>
<property name="jvmdebug" value="-Dadobe.aem.demo=nodebug"/>
</else>
</if>
<!-- Calculate dynamicmedia runmode for 6.2 and beyond, on Author only -->
<if>
<and>
<equals arg1="${demomachine.dynamicmedia}" arg2="true" casesensitive="false"/>
<equals arg1="${demo.mode}" arg2="author" casesensitive="false"/>
<or>
<equals arg1="${cq.version}" arg2="6.2" casesensitive="false"/>
<equals arg1="${cq.version}" arg2="6.3" casesensitive="false"/>
</or>
</and>
<then>
<property name="dynamicmedia.runmode" value=",dynamicmedia"/>
<echo message="Setting dynamic media runmode"/>
</then>
<else>
<property name="dynamicmedia.runmode" value=""/>
</else>
</if>
<!-- Calculate if we need the nosamples runmode -->
<if>
<equals arg1="${demo.nosamples}" arg2="true" casesensitive="false"/>
<then>
<property name="nosamples.runmode" value=",nosamples"/>
<echo message="Setting no samples runmode"/>
</then>
<else>
<property name="nosamples.runmode" value=""/>
</else>
</if>
<if>
<equals arg1="${demomachine.store}" arg2="crx3,crx3mongo" casesensitive="false"/>
<!-- AEM6.x MongoMK use case -->
<then>
<echo message="Starting in ${demo.mode} run mode, on port ${demo.port} using Mongo DB..."/>
<java dir="${demos}/${demo.build}/${demo.instance}" jar="${demos}/${demo.build}/${demo.instance}/aem-${demo.mode}-p${demo.port}.jar" fork="true" spawn="true">
<jvmarg value="-Xms${AdobeAEM.memorymin}"/>
<jvmarg value="-Xmx${AdobeAEM.memorymax}"/>
<jvmarg value="-XX:MaxPermSize=256m"/>
<jvmarg value="${jvmdebug}"/>
<jvmarg value="-Doak.mongo.db=${demo.mode}"/>
<jvmarg value="-Doak.mongo.uri=mongodb://${demo.mongo.host}:${demo.mongo.port}"/>
<jvmarg line="${demomachine.jvmargs}"/>
<arg value="-r ${demo.mode},${demomachine.store}${nosamples.runmode}${dynamicmedia.runmode}"/>
<arg value="-gui"/>
</java>
</then>
<else>
<if>
<equals arg1="${demo.license}" arg2="aem6" casesensitive="false"/>
<then>
<!-- AEM6.x use case -->
<echo message="Starting in ${demo.mode} run mode, on port ${demo.port} using ${demo.store}..."/>
<java dir="${demos}/${demo.build}/${demo.instance}" jar="${demos}/${demo.build}/${demo.instance}/aem-${demo.mode}-p${demo.port}.jar" fork="true" spawn="true">
<jvmarg value="-Xms${AdobeAEM.memorymin}"/>
<jvmarg value="-Xmx${AdobeAEM.memorymax}"/>
<jvmarg value="-XX:MaxPermSize=256m"/>
<jvmarg value="${jvmdebug}"/>
<jvmarg line="${demomachine.jvmargs}"/>
<arg value="-r ${demo.mode},${demomachine.store}${nosamples.runmode}${dynamicmedia.runmode}"/>
<arg value="-gui"/>
</java>
</then>
<else>
<!-- CQ5.x or AEM6.0 use case-->
<echo message="Starting in ${demo.mode} run mode, on port ${demo.port} using CRX2..."/>
<java dir="${demos}/${demo.build}/${demo.instance}" jar="${demos}/${demo.build}/${demo.instance}/aem-${demo.mode}-p${demo.port}.jar" fork="true" spawn="true">
<jvmarg value="-Xms${AdobeAEM.memorymin}"/>
<jvmarg value="-Xmx${AdobeAEM.memorymax}"/>
<jvmarg value="-XX:MaxPermSize=256m"/>
<jvmarg value="${jvmdebug}"/>
<jvmarg line="${demomachine.jvmargs}"/>
<arg value="-r ${demo.mode}"/>
<arg value="-gui"/>
</java>
</else>
</if>
</else>
</if>
</target>
<!-- Target for starting the JAMES smtp server -->
<target name="james_start" depends="os_detect">
<echo message="Starting the James SMTP/POP server..."/>
<chmod dir="${james}/bin" perm="ugo+rx" includes="*.sh"/>
<if>
<and>
<resourceexists>
<file file="${james}/bin/run.${os.cmd}"/>
</resourceexists>
<not>
<or>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.smtp}"/>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.jmx}"/>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.pop}"/>
</or>
</not>
</and>
<then>
<exec executable="${james}/bin/run.${os.cmd}" dir="${james}/bin" spawn="true"/>
<sleep seconds="2"/>
<waitfor maxwait="300" maxwaitunit="second" checkevery="2" checkeveryunit="second">
<and>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.smtp}"/>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.jmx}"/>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.pop}"/>
</and>
</waitfor>
</then>
</if>
</target>
<!-- Target for listing the JAMES smtp server configuration -->
<target name="james_config" depends="os_detect">
<if>
<resourceexists>
<file file="${james}/bin/james-cli.${os.cmd}"/>
</resourceexists>
<then>
<echo message="Listing the registered domains..."/>
<exec executable="${james}/bin/james-cli.${os.cmd}" dir="${james}/bin" spawn="false">
<arg line="-h ${demo.emailserver.hostname} -p ${demo.emailserver.jmx} listdomains"/>
</exec>
<echo message="Listing the registered users..."/>
<exec executable="${james}/bin/james-cli.${os.cmd}" dir="${james}/bin" spawn="false">
<arg line="-h ${demo.emailserver.hostname} -p ${demo.emailserver.jmx} listusers"/>
</exec>
<echo message="Listing the registered mappings..."/>
<exec executable="${james}/bin/james-cli.${os.cmd}" dir="${james}/bin" spawn="false">
<arg line="-h ${demo.emailserver.hostname} -p ${demo.emailserver.jmx} listmappings"/>
</exec>
</then>
</if>
</target>
<!-- Target for installing and configuring the JAMES smtp server -->
<target name="install_james" depends="james_stop">
<if>
<and>
<not>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.smtp}"/>
</not>
<not>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.pop}"/>
</not>
<not>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.jmx}"/>
</not>
</and>
<then>
<delete dir="${james}"/>
<unzip src="${dist}/downloads/james.zip" dest="."/>
<move file="./apache-james-3.0-${demo.emailserver.version}" tofile="${james}"/>
<chmod dir="${james}/bin" perm="ugo+rx" includes="*"/>
<copy todir="${james}/conf" overwrite="true">
<fileset dir="${dist}/james">
<include name="*.conf"/>
<include name="*.properties"/>
</fileset>
</copy>
<copy todir="${james}/conf/lib" overwrite="true">
<fileset dir="${dist}/james">
<include name="*.jar"/>
</fileset>
</copy>
<replace file="${james}/conf/smtpserver.conf" token="@@PORT_SMTP@@" value="${demo.emailserver.smtp}"/>
<replace file="${james}/conf/pop3server.conf" token="@@PORT_POP@@" value="${demo.emailserver.pop}"/>
<replace file="${james}/conf/jmx.properties" token="@@PORT_JMX@@" value="${demo.emailserver.jmx}"/>
<replace file="${james}/conf/imapserver.conf" token="@@PORT_IMAP@@" value="${demo.emailserver.imap}"/>
<antcall target="james_setup"/>
</then>
</if>
</target>
<target name="james_setup" depends="os_detect">
<if>
<resourceexists>
<file file="${james}/bin/james-cli.${os.cmd}"/>
</resourceexists>
<then>
<antcall target="james_start"/>
<echo message="Loading up domains..."/>
<propertyselector property="constituents" match="demo.emailserver.domains.([^\.]*)" select="\1" casesensitive="false"/>
<if>
<and>
<isset property="constituents"/>
<not>
<equals arg1="${constituents}" arg2=""/>
</not>
</and>
<then>
<foreach list="${constituents}" target="james_install_domain" param="domain.id"/>
</then>
</if>
<echo message="Loading up users..."/>
<propertyselector property="users" match="demo.emailserver.users.([^\.]*)" select="\1" casesensitive="false"/>
<if>
<and>
<isset property="users"/>
<not>
<equals arg1="${users}" arg2=""/>
</not>
</and>
<then>
<foreach list="${users}" target="james_install_user" param="user.id"/>
</then>
</if>
</then>
</if>
<antcall target="james_stop"/>
</target>
<!-- Target for detecting OS extension -->
<target name="os_detect">
<if>
<os family="unix"/>
<then>
<property name="os.cmd" value="sh"/>
</then>
<else>
<property name="os.cmd" value="bat"/>
</else>
</if>
</target>
<!-- Target for registering a new domain -->
<target name="james_install_domain" depends="os_detect">
<propertycopy property="domain.value" from="demo.emailserver.domains.${domain.id}"/>
<echo message="Loading up domain ${domain.value}..."/>
<exec executable="${james}/bin/james-cli.${os.cmd}" dir="${james}/bin" spawn="false">
<arg line="-h ${demo.emailserver.hostname} -p ${demo.emailserver.jmx} adddomain ${domain.value}"/>
</exec>
</target>
<!-- Target for registering a new user -->
<target name="james_install_user" depends="os_detect">
<propertycopy property="user.value" from="demo.emailserver.users.${user.id}"/>
<echo message="Loading up user ${user.value}..."/>
<exec executable="${james}/bin/james-cli.${os.cmd}" dir="${james}/bin" spawn="false">
<arg line="-h ${demo.emailserver.hostname} -p ${demo.emailserver.jmx} adduser ${user.value} ${demo.emailserver.password}"/>
</exec>
</target>
<!-- Target for killing the JAMES smtp server, if needed -->
<target name="james_stop_unix" if="isUnix" depends="permissions">
<exec executable="${bin}/kill.sh" dir="${bin}" spawn="false">
<arg line="james"/>
</exec>
</target>
<target name="james_stop_win" if="isWindows" depends="permissions">
<echo message="Stopping James on Windows is not implemented yet..."/>
</target>
<!-- Target for downloading the SOLR software -->
<target name="download_solr">
<echo message="Downloading Apache SOLR (from Apache Archives, might be slow...)"/>
<mkdir dir="${dist}/downloads"/>
<echo message="Downloading http://archive.apache.org/dist/lucene/solr/${demo.solr}/solr-${demo.solr}.tgz"/>
<exec executable="curl">
<arg line="-s -o '${dist}/downloads/solr.tgz' http://archive.apache.org/dist/lucene/solr/${demo.solr}/solr-${demo.solr}.tgz"/>
</exec>
</target>
<!-- Target for installing the SOLR software -->
<target name="install_solr" depends="solr_stop">
<echo message="Installing Apache SOLR"/>
<delete dir="${solr}"/>
<mkdir dir="${solr}"/>
<gunzip src="${dist}/downloads/solr.tgz" dest="${dist}/downloads/solr.tar"/>
<untar src="${dist}/downloads/solr.tar" dest="."/>
<move file="./solr-${demo.solr}" tofile="${solr}"/>
<chmod dir="${solr}/bin" perm="ugo+rx" includes="*"/>
<copy todir="${solr}/example/solr/collection1/conf" overwrite="true">
<fileset dir="${dist}/community/solr">
<include name="*"/>
</fileset>
</copy>
</target>
<!-- Target for starting the SOLR server -->
<target name="solr_start">
<if>
<socket server="${demo.solr.hostname}" port="${demo.solr.port}"/>
<then>
<echo message="The SOLR server is already started..."/>
</then>
<else>
<if>
<and>
<resourceexists>
<file file="${solr}/bin/solr"/>
</resourceexists>
<os family="unix"/>
</and>
<then>
<echo message="Starting the SOLR server (Unix)..."/>
<exec executable="${solr}/bin/solr" dir="${solr}/bin" spawn="true">
<arg line="start"/>
</exec>
</then>
</if>
<if>
<and>
<resourceexists>
<file file="${solr}/bin/solr.cmd"/>
</resourceexists>
<os family="windows"/>
</and>
<then>
<echo message="Starting the SOLR server (Windows)..."/>
<exec executable="${solr}/bin/solr.cmd" dir="${solr}/bin" spawn="true">
<arg line="start"/>
</exec>
</then>
</if>
<sleep seconds="2"/>
<waitfor maxwait="300" maxwaitunit="second" checkevery="2" checkeveryunit="second">
<socket server="${demo.solr.hostname}" port="${demo.solr.port}"/>
</waitfor>
</else>
</if>
</target>
<!-- Target for stopping the SOLR server -->
<target name="solr_stop">
<if>
<and>
<socket server="${demo.solr.hostname}" port="${demo.solr.port}"/>
<resourceexists>
<file file="${solr}/bin/solr"/>
</resourceexists>
</and>
<then>
<echo message="Stopping the SOLR server..."/>
<if>
<os family="unix"/>
<then>
<exec executable="${solr}/bin/solr" dir="${solr}/bin" failonerror="false" failifexecutionfails="false" spawn="true">
<arg line="stop -all"/>
</exec>
</then>
</if>
<if>
<os family="windows"/>
<then>
<exec executable="${solr}/bin/solr.cmd" dir="${solr}/bin" failonerror="false" failifexecutionfails="false" spawn="true">
<arg line="stop -all"/>
</exec>
</then>
</if>
<sleep seconds="2"/>
<waitfor maxwait="300" maxwaitunit="second" checkevery="2" checkeveryunit="second">
<not>
<socket server="${demo.solr.hostname}" port="${demo.solr.port}"/>
</not>
</waitfor>
<antcall target="solr_stop_unix"/>
</then>
</if>
</target>
<!-- Target for killing the SOLR server, if needed -->
<target name="solr_stop_unix" if="isUnix" depends="permissions">
<exec executable="${bin}/kill.sh" dir="${bin}" spawn="false">
<arg line="solr"/>
</exec>
</target>
<!-- Target for stopping the JAMES smtp server -->
<target name="james_stop" depends="os_detect">
<if>
<and>
<resourceexists>
<file file="${james}/bin/run.${os.cmd}"/>
</resourceexists>
<socket server="${demo.emailserver.hostname}" port="${demo.emailserver.smtp}"/>
</and>
<then>
<echo message="Stopping the James SMTP/POP server..."/>
<antcall target="james_stop_unix"/>
<antcall target="james_stop_win"/>
</then>
</if>
</target>
<!-- Target for starting the MYSQL server -->
<target name="mysql_start">
<if>
<and>
<equals arg1="${demo.mysql.external}" arg2="false" casesensitive="false"/>
<resourceexists>
<file file="${mysql}/bin/mysql"/>
</resourceexists>
</and>
<then>
<if>
<socket server="${demo.mysql.host}" port="${demo.mysql.port}"/>
<then>
<echo message="The MySQL server is already started..."/>
</then>
<else>
<echo message="Starting the MySQL server..."/>
<exec executable="./bin/mysqld" dir="${mysql}" spawn="true">
<arg line="--basedir='${mysql}' --datadir='${mysql}/data/'"/>
</exec>
<sleep seconds="2"/>
<waitfor maxwait="300" maxwaitunit="second" checkevery="2" checkeveryunit="second">
<socket server="${demo.mysql.host}" port="${demo.mysql.port}"/>
</waitfor>
</else>
</if>
</then>
</if>
</target>
<!-- Target for stopping the MySQL server -->
<target name="mysql_stop">
<if>
<and>