-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
807 lines (662 loc) · 34.1 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
<?xml version="1.0" encoding="UTF-8"?>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# ____ _ _ ___ ____ __ __ ____ _________ _
# \__\ \ \ \ \ \ _ _____________ __
# \ \ \__\ \ \__\ __ __ ______/ |
# _________ _____ _____ _________ _________| \_
# | \ \ \ / / | \ ____ \_ `-_
# | __ | \ \ / / | __ | / \ 4 5. \
# | |__) | \ V / | |__) | / /3 6\ \
# | ___/ \ / | < | |2 / 7| |
# | | | | | |\ \ \ \1 / 8/ /
# | | | | | | \ \ \ `-.-.-' /
# |_____| |_____| |_____| \____\ '-_ _-'
# `- - - '
# PyroCMS Deploy Tool v1.5
#
# This build file is desgined to automate the installation process
# of PyroCMS 3 apps, their addons, underlying framework (i.e. Laravel,
# PyroCMS etc) and perform various tasks such as, installing front-end,
# npm, composer dependancies as well as providing development tools,
# for example, reinstall / uninstall addons among other things.
#
# Type 'ant' or 'ant -projecthelp' to get a list of
# available targets
#
# 2011-2016 Web Semantics, Inc.
# All Rights Reserved.
#
# @link http://websemantics.ca
# @link http://ibuild.io
# @author WebSemantics, Inc. <info@websemantics.ca>
# @author Adnan M.Sagar, PhD. <adnan@websemantics.ca>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<project default="default" basedir="." name="Deploy a PyroCMS project" xmlns:liquibase="antlib:liquibase.integration.ant">
<description>Automate the installation of the current project</description>
<dirname property="project.dir" file="${ant.file}"/>
<include file="${project.dir}/vagrant.xml" as="vagrant"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# D E F A U L T T A R G E T : The default target to start project install
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="default" depends="install" description="The default target to start project install"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Installs this project and runs post install tasks
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install" depends="run-artisan-commands" description="Installs this project and runs post install tasks">
<echo message="Post-install actions ..."/>
<!-- Example 1 : Install bower dependencies
<exec dir="${app.dir}/public/js" executable="${env.BOWER.bin}">
<arg line="install - -force-latest"/>
</exec> -->
<!-- Example 2 : Install Node.js Less package
<exec dir="${app.dir}" executable="${env.NPM.bin}">
<arg line=" i less"/>
</exec> -->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Run artisan commands
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="run-artisan-commands" depends="require-install-addons" description="Run artisan commands">
<!-- <echo message="Run artisan commands ..."/>
<for list="${env.ARTISAN}" param="command" delimiter=";">
<sequential>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan @{command}"/>
</exec>
</sequential>
</for> -->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Requires and installs project addons and all the
# front-end, css, npm, grunt libraries
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="require-install-addons" depends="install-pyro" description="Requires and installs project addons and all the front-end, css, npm, grunt libraries">
<!-- <echo message="Requiring and installing project addons ..."/>
<for list="${env.APP_ADDONS}" param="package">
<sequential>
<addon package="@{package}"/>
</sequential>
</for> -->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Installs PyroCMS by running migrations, installing/seeding
# core modules/addons and creating the project .env file
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install-pyro" depends="create-database" description="Installs PyroCMS by running migrations, installing/seeding core modules/addons and creating the project .env file">
<echo message="Starting PyroCMS installation ... "/>
<touch file="${env.file}"/>
<echo message="- Creating project .env file ..."/>
<echo message="APP_DEBUG=${env.APP_DEBUG} " append="true" file="${env.file}"/>
<echo message="APP_ENV=${env.APP_ENV} " append="true" file="${env.file}"/>
<echo message="INSTALLED=false " append="true" file="${env.file}"/>
<echo message="APP_KEY=${env.APP_KEY} " append="true" file="${env.file}"/>
<echo message="DB_CONNECTION=${env.DB_CONNECTION} " append="true" file="${env.file}"/>
<echo message="DB_HOST=${env.DB_HOST} " append="true" file="${env.file}"/>
<echo message="DB_DATABASE=${env.DB_DATABASE} " append="true" file="${env.file}"/>
<echo message="DB_USERNAME=${env.DB_USERNAME} " append="true" file="${env.file}"/>
<echo message="DB_PASSWORD=${env.DB_PASSWORD} " append="true" file="${env.file}"/>
<echo message="DB_PORT=${env.DB_PORT} " append="true" file="${env.file}"/>
<echo message="APPLICATION_NAME=${env.APPLICATION_NAME} " append="true" file="${env.file}"/>
<echo message="APPLICATION_DOMAIN=${env.APPLICATION_DOMAIN} " append="true" file="${env.file}"/>
<echo message="APPLICATION_REFERENCE=${env.APPLICATION_REFERENCE} " append="true" file="${env.file}"/>
<echo message="APP_URL=${env.APP_URL} " append="true" file="${env.file}"/>
<echo message="APP_TIMEZONE=${env.APP_TIMEZONE} " append="true" file="${env.file}"/>
<echo message="ADMIN_USERNAME=${env.ADMIN_USERNAME} " append="true" file="${env.file}"/>
<echo message="ADMIN_EMAIL=${env.ADMIN_EMAIL} " append="true" file="${env.file}"/>
<echo message="ADMIN_PASSWORD=${env.ADMIN_PASSWORD} " append="true" file="${env.file}"/>
<echo message="ADMIN_THEME=${env.ADMIN_THEME} " append="true" file="${env.file}"/>
<echo message="STANDARD_THEME=${env.STANDARD_THEME} " append="true" file="${env.file}"/>
<echo message="DEFAULT_LOCALE=${env.DEFAULT_LOCALE} " append="true" file="${env.file}"/>
<echo message="- Generating a fresh application key ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan key:generate"/>
</exec>
<echo message="- Running core migrations ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan migrate --force --path=vendor/anomaly/streams-platform/migrations/core"/>
</exec>
<echo message="- Running application migrations ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan migrate --force --path=vendor/anomaly/streams-platform/migrations/application"/>
</exec>
<echo message="- Installing core modules (and, remove excluded) ..."/>
<for list="${env.CORE_MODULES}" param="module">
<sequential>
<if>
<contains string="${env.MODULE_EXCLUDES}" substring="@{module}"/>
<then>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="remove anomaly/@{module}-module"/>
</exec>
</then>
<else>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan addon:install --app ${env.APPLICATION_REFERENCE} anomaly.module.@{module}"/>
</exec>
</else>
</if>
</sequential>
</for>
<echo message="- Installing core extensions (and, remove excluded) ..."/>
<for list="${env.CORE_EXTENSIONS}" param="extension">
<sequential>
<if>
<contains string="${env.EXTENSION_EXCLUDES}" substring="@{extension}"/>
<then>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="remove anomaly/@{extension}-extension"/>
</exec>
</then>
<else>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan addon:install --app ${env.APPLICATION_REFERENCE} anomaly.extension.@{extension}"/>
</exec>
</else>
</if>
</sequential>
</for>
<for list="${env.PLUGIN_EXCLUDES}" param="plugin">
<sequential>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="remove anomaly/@{plugin}-plugin"/>
</exec>
</sequential>
</for>
<echo message="- Change to installed state ..."/>
<replace file="${env.file}" token="INSTALLED=false" value="INSTALLED=true"/>
<echo message="- Running base migrations ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan migrate --force"/>
</exec>
<echo message="- Seeding core modules ..."/>
<for list="${env.CORE_MODULES}" param="module">
<sequential>
<if>
<or>
<contains string="${env.SEED_EXCLUDES}" substring="@{module}"/>
<contains string="${env.MODULE_EXCLUDES}" substring="@{module}"/>
</or>
<else>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan db:seed --force --addon anomaly.module.@{module}"/>
</exec>
</else>
</if>
</sequential>
</for>
<echo message="- Seeding core extensions ..."/>
<for list="${env.CORE_EXTENSIONS}" param="extension">
<sequential>
<if>
<or>
<contains string="${env.SEED_EXCLUDES}" substring="@{extension}"/>
<contains string="${env.EXTENSION_EXCLUDES}" substring="@{extension}"/>
</or>
<else>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan db:seed --force --addon anomaly.extension.@{extension}"/>
</exec>
</else>
</if>
</sequential>
</for>
<echo message="- Create application instance ..."/>
<sql driver="com.mysql.cj.jdbc.Driver" url="${db.server.url}" userid="${db.user}"
password="${db.pass}" classpathref="jdbc.classpath"><![CDATA[
INSERT INTO ${db.name}.applications (name,reference,domain,enabled)
VALUES('${env.APPLICATION_NAME}','${env.APPLICATION_REFERENCE}','${env.APPLICATION_DOMAIN}',true); ]]>
</sql>
<echo message="- Seeding base ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan db:seed"/>
</exec>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Create Database
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="create-database" depends="composer-dependencies" description="Create database">
<echo message="- Creating ${db.name} database ... ${db.server.url} ${app.dir}/lib"/>
<if>
<equals arg1="${env.DB_DROP}" arg2="true"/>
<then>
<sql driver="com.mysql.cj.jdbc.Driver" url="${db.server.url}" userid="${db.user}"
password="${db.pass}" classpathref="jdbc.classpath"><![CDATA[
DROP DATABASE IF EXISTS ${db.name}; ]]>
</sql>
</then>
</if>
<sql driver="com.mysql.cj.jdbc.Driver" url="${db.server.url}" userid="${db.user}"
password="${db.pass}" classpathref="jdbc.classpath"><![CDATA[
CREATE DATABASE IF NOT EXISTS ${db.name}; ]]>
</sql>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Require / Remove composer packages
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="composer-dependencies" depends="require-pyro" description="Require and remove composer packages">
<if>
<equals arg1="${setup}" arg2="true"/>
<then>
<echo message="Run composer ..."/>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="install"/>
</exec>
<for list="${env.COMPOSER.require}" param="package">
<sequential>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="require @{package}"/>
</exec>
</sequential>
</for>
<for list="${env.COMPOSER.remove}" param="package">
<sequential>
<exec dir="${app.dir}" executable="${env.COMPOSER.bin}">
<arg line="remove @{package}"/>
</exec>
</sequential>
</for>
</then>
</if>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Clone PyroCMS and copy its files to project folder
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="require-pyro" depends="clean" description="Clone PyroCMS and copy its files to project folder">
<if>
<equals arg1="${setup}" arg2="true"/>
<then>
<echo message="Clone a fresh copy of pyrocms ... "/>
<exec dir="${app.dir}" executable="${env.GIT.bin}">
<arg line="clone"/>
<arg line="-b"/>
<arg line="${env.PYRO.branch}"/>
<arg line="${env.PYRO.repo}"/>
<arg line="${pyro.dir}"/>
</exec>
<echo message="Move PyroCMS files into the project folder ..."/>
<!-- move root folders -->
<for list="${env.PYRO_FOLDERS}" param="folder">
<sequential>
<move file="${pyro.dir}/@{folder}" todir="${app.dir}" includeEmptyDirs="yes" failonerror="${failonerror}" quiet="${quiet}"/>
</sequential>
</for>
<!-- move folders inside public -->
<for list="${env.PUBLIC_FOLDERS}" param="folder">
<sequential>
<move file="${pyro.dir}/public/@{folder}" todir="${app.dir}/public" includeEmptyDirs="yes" failonerror="${failonerror}" quiet="${quiet}"/>
</sequential>
</for>
<!-- move root folder files -->
<for list="${env.ROOT_FILES}" param="file">
<sequential>
<move file="${pyro.dir}/@{file}" todir="${app.dir}" failonerror="${failonerror}" quiet="${quiet}"/>
</sequential>
</for>
<!-- move files from public folder -->
<move todir="${app.dir}/public">
<fileset dir="${pyro.dir}/public">
<include name="**/*.*"/>
</fileset>
</move>
<echo message="Remove PyroCMS temporary folder ..."/>
<delete dir="${pyro.dir}" failonerror="${failonerror}"/>
</then>
</if>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Delete temp folders and the project .env file
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="clean" depends="init" description="Delete temp folders and the project .env file">
<delete file="${env.file}" failonerror="${failonerror}"/>
<delete dir="${pyro.dir}" failonerror="${failonerror}"/>
<delete dir="${laravel.dir}" failonerror="${failonerror}"/>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Loads project properties, task definitions and other
# environment settings
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="init" description="Loads project properties, task definitions and other environment settings">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# L O A D P R O P E R T I E S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<property environment="env"/>
<property file="local.properties"/>
<property name="app.dir" value="${user.dir}"/>
<property name="pyro.dir" value="${app.dir}/pyro"/>
<property name="laravel.dir" value="${app.dir}/laravel"/>
<property name="env.file" value="${app.dir}/.env"/>
<property name="setup" value="true"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# D A T A B A S E P R O P E R T I E S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<property name="db.changelog.file" value="changelog.xml"/>
<property name="db.server.url" value="jdbc:mysql://${env.DB_HOST}:${env.DB_PORT}"/>
<property name="db.url" value="jdbc:mysql://${env.DB_HOST}:${env.DB_PORT}/${env.DB_DATABASE}"/>
<property name="db.user" value="${env.DB_USERNAME}"/>
<property name="db.pass" value="${env.DB_PASSWORD}"/>
<property name="db.name" value="${env.DB_DATABASE}"/>
<property name="db.driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="db.dropFirst" value="true"/>
<!-- Set jdbc folder path -->
<path id="jdbc.classpath">
<fileset dir="${app.dir}/lib">
<include name="mysql-connector-java-8.0.17.jar"/>
</fileset>
</path>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# D O W N L O A D A N T D E P E N D E N C I E S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<mkdir dir="${app.dir}/lib"/>
<!-- Ant-contrib -->
<get src="https://repo1.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar" dest="${app.dir}/lib/ant-contrib-1.0b3.jar" usetimestamp="true" skipexisting="true" ignoreerrors="${ignoreerrors}" quiet="${quiet}"/>
<!-- MySql-connector -->
<get src="https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.17/mysql-connector-java-8.0.17.jar" dest="${app.dir}/lib/mysql-connector-java-8.0.17.jar" usetimestamp="true" skipexisting="true" ignoreerrors="${ignoreerrors}" quiet="${quiet}"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# T A S K D E F I N I T I O N S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Include Ant Contrin Tasks -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${app.dir}/lib/ant-contrib-1.0b3.jar"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# L I Q U I B A S E D A T A B A S E
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<equals arg1="${env.LIQUIBASE}" arg2="true"/>
<then>
<path id="liquibase.classpath">
<fileset dir="${app.dir}/lib/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${app.dir}/lib">
<include name="liquibase.jar" />
</fileset>
</path>
<!-- download libraries -->
<get src="https://github.com/liquibase/liquibase/releases/download/liquibase-parent-3.5.1/liquibase-3.5.1-bin.zip" dest="${app.dir}/lib/liquibase-3.5.1-bin.zip" usetimestamp="true" skipexisting="true" ignoreerrors="${ignoreerrors}" quiet="${quiet}"/>
<unzip src="${app.dir}/lib/liquibase-3.5.1-bin.zip" dest="${app.dir}/lib"/>
<!-- define tasks -->
<taskdef resource="liquibase/integration/ant/antlib.xml" uri="antlib:liquibase.integration.ant">
<classpath refid="liquibase.classpath" />
</taskdef>
<!-- define database reference -->
<liquibase:database id="db" driver="${db.driver}" url="${db.url}" user="${db.user}"
password="${db.pass}" defaultSchemaName="${db.name}" />
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# D E B U G P R O P E R T I E S
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<property name="debug" value="${env.DEBUG}"/>
<if>
<equals arg1="${debug}" arg2="true"/>
<then>
<property name="ignoreerrors" value="false"/>
<property name="failonerror" value="true"/>
<property name="quiet" value="false"/>
</then>
<else>
<property name="ignoreerrors" value="true"/>
<property name="failonerror" value="false"/>
<property name="quiet" value="true"/>
</else>
</if>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Install project addons (development helper task).
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install-addons" depends="init" description="Install project addons">
<!-- Example to install an extension
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan extension:install vendor.extension.name"/>
</exec>
-->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Uninstall project addons (development helper task).
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="uninstall-addons" depends="init" description="Uninstall project addons">
<!-- Example to uninstall an extension
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan extension:uninstall vendor.extension.name"/>
</exec>
-->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# T A R G E T : Reinstall project addons (development helper task).
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="reinstall-addons" depends="init" description="Reinstall project addons">
<antcall target="uninstall-addons"/>
<antcall target="install-addons"/>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# M A C R O : Require - Install / Uninstall or Reinstall an
# addon (Module, Extension, Field Type etc) and optional
# seeding, run composer, bower, npm and grunt if at all.
#
# This marcro will also accept plugin, theme, field-type
# addons but will only install Module and Extension types.
#
# @param package, the addon name and optional url (joined by a pipe '|'),
# for example, websemantics.extension.entity_builder or
# websemantics.extension.entity_builder|url (github etc)
# It gets split into 'vendor', 'type', 'name' and optional url
#
# @param action, this param defaults to 'install' (reinstall or
# uninstall). Once all is done, the macro will install,
# uninstall or reinstall an addone based on its value
#
# @param url, if provided, attempt to clone the addon
# (remove if exists already)
#
# @param location, where to save in the 'addons' folder (default or shared),
# it defaults to 'default'
#
# @param seed, If set to 'true' (default) the addon is seeded after install.
#
# @param composer, If set to 'true' (default) then install
# all composer packages against the addon
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<macrodef name="addon">
<attribute name="package"/>
<attribute name="action" default="install"/>
<attribute name="location" default="default"/>
<attribute name="seed" default="true"/>
<attribute name="composer" default="true"/>
<sequential>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# G E T V E N D O R T Y P E S L U G
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<script language="javascript">
var name_url = "@{package}";
<![CDATA[
// Get the package full name (namespace) and optional url,
var arr = name_url.split('|');
var name = arr[0];
var url = arr[1]
? arr[1]
: 'null';
// Get the package vendor, type and slug
arr = name.split('.');
project.setProperty('vendor', arr[0]);
project.setProperty('type', arr[1]);
project.setProperty('slug', arr[2]);
project.setProperty('url', url);
project.setProperty('name', name);
]]>
</script>
<var name="addon.dir" value="${app.dir}/addons/@{location}/${vendor}/${slug}-${type}"/>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# C L O N E A D D O N R E P O S I T O R Y
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<equals arg1="${url}" arg2="null"/>
<else>
<!-- Make sure to remove the addon if already there -->
<delete dir="${addon.dir}" failonerror="${failonerror}"/>
<echo message="cloning ${type} ${slug} (${name}) ..."/>
<exec dir="${app.dir}" executable="${env.GIT.bin}">
<arg line="clone"/>
<arg line="${url}"/>
<arg line="${addon.dir}"/>
</exec>
</else>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# R U N C O M P O S E R
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<and>
<available file="${addon.dir}/composer.json"/>
<equals arg1="@{composer}" arg2="true"/>
</and>
<then>
<exec dir="${addon.dir}" executable="${env.COMPOSER.bin}">
<arg line="install"/>
</exec>
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# R U N N P M
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<available file="${addon.dir}/package.json"/>
<then>
<exec dir="${addon.dir}" executable="${env.NPM.bin}">
<arg line=" i"/>
</exec>
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# R U N B O W E R
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<available file="${addon.dir}/bower.json"/>
<then>
<exec dir="${addon.dir}" executable="${env.BOWER.bin}">
<arg line="install --force-latest"/>
</exec>
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# R U N G R U N T
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<available file="${addon.dir}/gruntfile.js"/>
<then>
<exec dir="${addon.dir}" executable="${env.GRUNT.bin}">
<arg line="--force"/>
</exec>
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# I N S T A L L
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<or>
<equals arg1="${type}" arg2="module"/>
<equals arg1="${type}" arg2="extension"/>
</or>
<then>
<echo message="@{action}ing ${type} ${slug} (${name}) ..."/>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan ${type}:@{action} ${name}"/>
</exec>
</then>
</if>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# S E E D
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<if>
<or>
<equals arg1="${type}" arg2="module"/>
<equals arg1="${type}" arg2="extension"/>
</or>
<then>
<if>
<equals arg1="@{seed}" arg2="true"/>
<then>
<exec dir="${app.dir}" executable="${env.PHP.bin}">
<arg line="artisan db:seed --force --addon ${name}"/>
</exec>
</then>
</if>
</then>
</if>
</sequential>
</macrodef>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# E X P E R I M E N T A L T A R G E T : Update database with liquibase schema
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="update-database" depends="init" description="Update database with liquibase schema">
<liquibase:updateDatabase databaseref="db" changelogfile="${db.changelog.file}"
classpathref="jdbc.classpath" dropFirst="${drop_first}" logLevel="debug">
</liquibase:updateDatabase>
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# E X P E R I M E N T A L T A R G E T : Install PyroCMS on top of Laravel
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="install-laravel" depends="require-laravel" description="Install PyroCMS on top of Laravel">
<!-- more to come -->
</target>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# E X P E R I M E N T A L T A R G E T : Clone Laravel and copy all files to project folder
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<target name="require-laravel" depends="clean" description="Clone Laravel and copy all files to project folder.">
<echo message="Clone a fresh copy of laravel ... "/>
<exec dir="${app.dir}" executable="${env.GIT.bin}">
<arg line="clone"/>
<arg line="https://github.com/laravel/laravel"/>
<arg line="${laravel.dir}"/>
</exec>
<echo message="Move laravel folders/files into project folder ..."/>
<for list="app,storage,bootstrap,database,config,tests,resources" param="folder">
<sequential>
<move file="${laravel.dir}/@{folder}" todir="${app.dir}" includeEmptyDirs="yes" failonerror="${failonerror}" quiet="${quiet}"/>
</sequential>
</for>
<move todir="${app.dir}" failonerror="${failonerror}" quiet="${quiet}">
<filelist dir="${laravel.dir}">
<file name="artisan"/>
<file name="server.php"/>
<file name="composer.json"/>
</filelist>
</move>
<move file="${laravel.dir}/public/assets" todir="${app.dir}/public" includeEmptyDirs="yes" failonerror="${failonerror}" quiet="${quiet}"/>
<move file="${laravel.dir}/public/packages" todir="${app.dir}/public" includeEmptyDirs="yes" failonerror="${failonerror}" quiet="${quiet}"/>
<move todir="${app.dir}/public" failonerror="${failonerror}" quiet="${quiet}">
<fileset dir="${laravel.dir}/public">
<include name="**/*.*"/>
</fileset>
</move>
<echo message="Remove laravel folder ..."/>
<delete dir="${laravel.dir}" failonerror="${failonerror}"/>
</target>
</project>