-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.xml
More file actions
609 lines (609 loc) · 29.8 KB
/
Copy pathbase.xml
File metadata and controls
609 lines (609 loc) · 29.8 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<project default="build">
<!-- Sets the default properties. Override in your build file when needed. -->
<property environment="env"/>
<property name="project" value="base-build-xml"/>
<property name="drupalroot" value="docroot"/>
<property name="drupalsite" value="default"/>
<!-- Drupal default credentials. -->
<property name="db.url" value="sqlite://db.sqlite"/>
<property name="admin.user" value="admin"/>
<property name="admin.pass" value="admin"/>
<!-- Path to Drupal themes. -->
<property name="drupalthemes" value="sites/all/themes"/>
<!-- Path to Drupal modules. -->
<property name="drupalmodules" value="sites/all/modules"/>
<!-- Path to Drupal libraries. -->
<property name="drupallibraries" value="sites/all/libraries"/>
<!-- Path to Drupal files. -->
<property name="drupalfiles" value="sites/${drupalsite}/files"/>
<!-- Drupal URL. -->
<property name="drushurl" value=""/>
<!-- Path to existing Drupal's db file to import. -->
<property name="drupaldbfile" value="drupal.sql"/>
<!-- Path to existing file with list of modules to enable. -->
<property name="modules-contrib-file" value="contrib.txt"/>
<property name="modules-custom-file" value="custom.txt"/>
<property name="modules-devel-file" value="devel.txt"/>
<property name="modules-features-file" value="features.txt"/>
<!-- Define Composer's main directory (location of composer.json file). -->
<property name="composerdir" value="${basedir}"/>
<!-- Composer's vendor dir. -->
<property name="vendordir" value="${composerdir}/vendor"/>
<!-- Define Composer's bin-dir. -->
<property name="vendorbindir" value="${vendordir}/bin"/>
<!-- Define Composer's executable binary file. -->
<property name="composerbinfile" value="${vendorbindir}/composer.phar"/>
<property name="composersite" value="all"/>
<!-- Build dir for result files. -->
<property name="builddir" value="${composerdir}/build"/>
<!-- Base build scripts dir. -->
<property name="scriptsdir" value="${vendordir}/NT/base-build-xml/scripts"/>
<property name="fileexts" value="php,module,inc,install,profile,theme"/>
<property name="fileextsexp" value="*.php,*.module,*.inc,*.install,*.profile,*.theme"/>
<property name="phpunitxml" value="${composerdir}/phpunit-ci.xml"/>
<property name="pdependarg" value="--quiet"/>
<property name="webservicename" value=""/>
<property name="webservicerouterfile" value=""/>
<available file="${basedir}/${drupalroot}/index.php" property="drupal.exists"/>
<available file="${basedir}/${drupalroot}/sites/${drupalsite}/settings.php" property="drupal.settings.exists"/>
<available file="${basedir}/${drupalroot}/sites/${drupalsite}/example.settings.local.php" property="drupal.example.settings.exists"/>
<available file="${composerdir}/composer.skip" property="composer.executed"/>
<available file="${composerbinfile}" property="composer.exists"/>
<available file="${phpunitxml}" property="phpunit.xml.exists"/>
<available file="${drupaldbfile}" property="drupaldbfile.exists"/>
<available file="${basedir}/build.properties" property="build.properties.exists"/>
<!-- Verify the presence of files consisting list of modules to enable. -->
<available file="${basedir}/${modules-contrib-file}" property="contrib.txt.exists"/>
<available file="${basedir}/${modules-custom-file}" property="custom.txt.exists"/>
<available file="${basedir}/${modules-devel-file}" property="devel.txt.exists"/>
<available file="${basedir}/${modules-features-file}" property="features.txt.exists"/>
<!-- Load properties from the file when present. -->
<condition property="parallel-lint" value="${vendorbindir}/parallel-lint.bat" else="${vendorbindir}/parallel-lint">
<os family="windows"/>
</condition>
<target name="build" depends="prepare,parallel-lint,phploc,pdepend,phpmd-ci,phpcs-security-ci,phpcs-coder-ci,phpcpd,phpunit,behat,phpcov,combine-junit-xml,phpcb"/>
<target name="build-parallel" depends="prepare,run-tests,combine-junit-xml"/>
<target name="run-tests" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="docblox"/>
<antcall target="lint"/>
<antcall target="phpcb"/>
<antcall target="phpcov"/>
<antcall target="phpcpd"/>
<antcall target="phpcs-coder-ci"/>
<antcall target="phpcs-security-ci"/>
<antcall target="phploc"/>
<antcall target="phpunit"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${builddir}/api"/>
<delete dir="${builddir}/behat"/>
<delete dir="${builddir}/cache"/>
<delete dir="${builddir}/code-browser"/>
<delete dir="${builddir}/coverage"/>
<delete dir="${builddir}/logs"/>
<delete dir="${builddir}/pdepend"/>
<delete file="${composerdir}/composer.lock"/>
<delete file="${composerdir}/composer.skip"/>
</target>
<target name="prepare" depends="load-build-properties,clean,composer" description="Prepare for build">
<mkdir dir="${builddir}/api"/>
<mkdir dir="${builddir}/behat"/>
<mkdir dir="${builddir}/cache"/>
<mkdir dir="${builddir}/code-browser"/>
<mkdir dir="${builddir}/coverage"/>
<mkdir dir="${builddir}/logs"/>
<mkdir dir="${builddir}/logs/coverage"/>
<mkdir dir="${builddir}/logs/junit"/>
<mkdir dir="${builddir}/pdepend"/>
<mkdir dir="${builddir}/phpdox"/>
</target>
<target name="load-build-properties" description="Load properties from the file." if="build.properties.exists">
<property file="build.properties"/>
</target>
<!-- Define set of files -->
<fileset id="drupal.fileset" dir="${drupalroot}">
<include name="sites/**/*.php"/>
<include name="sites/**/*.inc"/>
<include name="sites/**/*.module"/>
<include name="sites/**/*.install"/>
<include name="sites/**/*.profile"/>
<include name="sites/**/*.theme"/>
<!-- Excludes Drupal files folder. -->
<exclude name="${drupalfiles}/*"/>
<!-- Excludes any vendor dirs within Drupal root. -->
<exclude name="sites/**/vendor/**"/>
<!-- Excludes coder_sniffer dir. -->
<exclude name="sites/**/coder_sniffer/Drupal/Test/**/*.php"/>
<!-- @see: https://github.com/symfony/symfony/issues/11921 -->
<exclude name="${drupallibraries}/**/Tests/**/*.php"/>
<!-- @see: https://github.com/symfony/polyfill/issues/108 -->
<exclude name="${drupallibraries}/**/Resources/**/*.php"/>
<modified>
<param name="cache.cachefile" value="${builddir}/cache/${project}.drupal.fileset.properties"/>
</modified>
</fileset>
<fileset id="composer.fileset" dir="${composerdir}">
<include name="**/*.php"/>
<!-- Excludes coder_sniffer dir. -->
<exclude name="vendor/**/coder_sniffer/Drupal/Test/**/*.php"/>
<!-- E.g. squizlabs/php_codesniffer/CodeSniffer -->
<exclude name="vendor/**/CodeSniffer/**"/>
<!-- Ignores all PHP files found within vendor dir. -->
<exclude name="vendor/**/*.php"/>
<!-- @see: https://github.com/symfony/polyfill/issues/108 -->
<exclude name="vendor/**/Resources/**/*.php"/>
<!-- E.g. vendor/jakub-onderka/php-parallel-lint/tests/examples -->
<exclude name="vendor/**/examples/**/*.php"/>
<!-- E.g. vendor/pdepend/pdepend/src/test/resources/files -->
<exclude name="vendor/**/resources/**/*.php"/>
<modified>
<param name="cache.cachefile" value="${builddir}/cache/${project}.composer.fileset.properties"/>
</modified>
</fileset>
<target name="lint" depends="prepare,drupal-core" if="drupal.exists">
<apply executable="php" parallel="true" verbose="true" dir="${basedir}" failonerror="true">
<arg value="-l"/>
<fileset refid="composer.fileset"/>
</apply>
<apply executable="php" parallel="true" verbose="true" dir="${basedir}" failonerror="true">
<arg value="-l"/>
<fileset refid="drupal.fileset"/>
</apply>
</target>
<target name="parallel-lint" description="Run PHP parallel lint" depends="prepare,drupal-core" if="drupal.exists">
<apply executable="${parallel-lint}" parallel="true" maxparallel="1000" dir="${basedir}" failonerror="true">
<arg line="-e"/>
<arg value="${fileexts}"/>
<fileset refid="composer.fileset"/>
</apply>
<apply executable="${parallel-lint}" parallel="true" maxparallel="1000" dir="${basedir}" failonerror="true">
<arg line="-e"/>
<arg value="${fileexts}"/>
<fileset refid="drupal.fileset"/>
</apply>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="${vendorbindir}/phploc">
<arg value="--log-csv"/>
<arg value="${builddir}/logs/phploc.csv"/>
<arg value="--names"/>
<arg value="${fileextsexp}"/>
<arg path="${drupalroot}/${drupalmodules}"/>
<arg path="${drupalroot}/${drupalthemes}"/>
</exec>
</target>
<target name="pdepend" depends="composer" description="Calculate software metrics using PHP_Depend" unless="pdepend.xml.present">
<exec executable="${vendorbindir}/pdepend">
<arg value="-d"/>
<arg value="memory_limit=256M"/>
<arg value="--suffix=${fileexts}"/>
<arg value="--jdepend-xml=${builddir}/logs/jdepend.xml"/>
<arg value="--jdepend-chart=${builddir}/pdepend/dependencies.svg"/>
<arg value="--overview-pyramid=${builddir}/pdepend/overview-pyramid.svg"/>
<arg value="--summary-xml=${builddir}/logs/pdepend.xml"/>
<arg value="${pdependarg}"/>
<arg path="${drupalmodules}"/>
</exec>
<available file="${builddir}/logs/pdepend.xml" property="pdepend.xml.present"/>
</target>
<target name="phpmd" depends="composer,drupal-core" description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${vendorbindir}/phpmd">
<arg value="--suffixes"/>
<arg value="${fileexts}"/>
<arg path="${drupalmodules}"/>
<arg value="text"/>
<!--<arg value="${builddir}/phpmd.xml"/>-->
<arg value="codesize,unusedcode,naming"/>
</exec>
</target>
<target name="phpmd-ci" depends="composer,drupal-core" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="${vendorbindir}/phpmd">
<arg value="--suffixes"/>
<arg value="${fileexts}"/>
<arg path="${drupalmodules}"/>
<arg value="xml"/>
<arg value="codesize,unusedcode,naming"/>
<!--<arg value="${builddir}/phpmd.xml"/>-->
<arg value="--reportfile"/>
<arg value="${builddir}/logs/pmd.xml"/>
</exec>
</target>
<target name="phpcs-check" depends="composer" description="Checks installed coding standards.">
<exec executable="${vendorbindir}/phpcs">
<arg value="-i"/>
</exec>
</target>
<target name="phpcs-coder" depends="composer,phpcs-check" if="drupal.exists" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<exec executable="${vendorbindir}/phpcs">
<arg value="-d"/>
<arg value="memory_limit=256M"/>
<arg value="--standard=Drupal,DrupalPractice"/>
<arg value="--extensions=${fileexts}"/>
<arg path="${drupalmodules}"/>
<arg path="${drupalthemes}"/>
</exec>
</target>
<target name="phpcs-coder-ci" depends="composer,phpcs-check" if="drupal.exists" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server.">
<exec executable="${vendorbindir}/phpcs">
<arg value="-d"/>
<arg value="memory_limit=256M"/>
<arg value="--standard=Drupal,DrupalPractice"/>
<arg value="--report=checkstyle"/>
<arg value="--report-file=${builddir}/logs/checkstyle.xml"/>
<arg value="--report-xml=${builddir}/logs/codesniffer.xml"/>
<arg value="--extensions=${fileexts}"/>
<arg path="${drupalmodules}"/>
<arg path="${drupalthemes}"/>
</exec>
</target>
<target name="phpcs-security" depends="composer,phpcs-check" description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<!-- @see: https://github.com/FloeDesignTechnologies/phpcs-security-audit/issues/2 -->
<symlink link="${vendordir}/squizlabs/php_codesniffer/CodeSniffer/Standards/Security"
resource="${vendordir}/pheromone/phpcs-security-audit/Security"
overwrite="true"/>
<exec executable="${vendorbindir}/phpcs">
<arg value="-d"/>
<arg value="memory_limit=256M"/>
<arg value="--standard=${vendordir}/pheromone/phpcs-security-audit/example_drupal7_ruleset.xml"/>
<arg value="--extensions={fileexts}"/>
<arg path="${drupalmodules}"/>
<arg path="${drupalthemes}"/>
</exec>
</target>
<target name="phpcs-security-ci" depends="composer,phpcs-check" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<!-- @see: https://github.com/FloeDesignTechnologies/phpcs-security-audit/issues/2 -->
<symlink link="${vendordir}/squizlabs/php_codesniffer/CodeSniffer/Standards/Security"
resource="${vendordir}/pheromone/phpcs-security-audit/Security"
overwrite="true"/>
<exec executable="${vendorbindir}/phpcs">
<arg value="-d"/>
<arg value="memory_limit=256M"/>
<arg value="--report=checkstyle"/>
<arg value="--standard=${vendordir}/pheromone/phpcs-security-audit/example_drupal7_ruleset.xml"/>
<arg value="--extensions=${fileexts}"/>
<arg value="--report-file=${builddir}/logs/checkstyle-security.xml"/>
<arg value="--report-xml=${builddir}/logs/codesniffer-security.xml"/>
<arg path="${drupalmodules}"/>
<arg path="${drupalthemes}"/>
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="${vendorbindir}/phpcpd">
<arg value="--log-pmd"/>
<arg value="${builddir}/logs/pmd-cpd.xml"/>
<arg value="--names"/>
<arg value="${fileextsexp}"/>
<arg value="--exclude"/>
<arg value="${vendordir}"/>
<arg path="${drupalmodules}"/>
</exec>
</target>
<target name="docblox" description="Generate API documentation using docblox">
<exec executable="${vendorbindir}/docblox">
<arg value="-d"/>
<arg value="${drupalmodules}"/>
<arg value="-t"/>
<arg value="${builddir}/phpdox"/>
</exec>
</target>
<target name="phpunit" description="Run unit tests with PHPUnit" depends="composer" if="phpunit.xml.exists">
<exec executable="${vendorbindir}/phpunit" failonerror="true">
<env key="PATH" value="${vendorbindir}:${env.PATH}"/>
<arg value="-d"/>
<arg value="memory_limit=2G"/>
<arg value="-c"/>
<arg value="${phpunitxml}"/>
<arg value="--testsuite"/>
<arg value="All Code"/>
<arg path="${drupalmodules}"/>
</exec>
</target>
<target name="behat" if="drupal.exists" description="Wrapper for BDD tests with Behat" depends="composer,phantomjs-start,php-webserver-start,web-service-start,enable-bdd-code-coverage,behat-test,behat-run">
<antcall target="web-service-stop"/>
<antcall target="php-webserver-stop"/>
<antcall target="phantomjs-stop"/>
<antcall target="database-drop"/>
<fail unless="BehatDryRun" message="Behat Dry run failed so there are faulty feature files" />
</target>
<target name="behat-run" description="Run BDD tests with Behat" depends="composer" if="BehatDryRun">
<exec executable="./bin/behat" failonerror="false" dir="${composerdir}">
<env key="PATH" value="${env.PATH}:${vendorbindir}"/>
<arg value="--profile"/>
<arg value="ci"/>
</exec>
</target>
<target name="behat-test" description="Dry Run BDD tests with Behat" depends="composer">
<exec executable="./bin/behat" failonerror="false" dir="${composerdir}" resultproperty="BehatErrorCode">
<env key="PATH" value="${env.PATH}:${vendorbindir}"/>
<arg value="--dry-run"/>
<arg value="--format"/>
<arg value="progress"/>
</exec>
<condition property="BehatDryRun">
<equals arg1="${BehatErrorCode}" arg2="0"/>
</condition>
</target>
<target name="behat-system" description="Wrapper for BDD tests with Behat" depends="composer,phantomjs-start,php-webserver-start,web-service-start,enable-bdd-code-coverage,behat-test,behat-system-run">
<antcall target="web-service-stop"/>
<antcall target="php-webserver-stop"/>
<antcall target="phantomjs-stop"/>
<antcall target="database-drop"/>
<fail unless="BehatDryRun" message="Behat Dry run failed so there are faulty feature files"/>
</target>
<target name="behat-system-run" description="Run BDD tests with Behat" depends="composer" if="BehatDryRun">
<exec executable="./bin/behat" failonerror="false" dir="${basedir}/tests">
<arg value="--profile" />
<arg value="systemTest" />
</exec>
</target>
<target name="phpcov" depends="composer" description="Generate HTML and clover output for coverage">
<exec executable="${vendorbindir}/phpcov">
<arg value="merge"/>
<arg value="--clover=${builddir}/coverage/combined_clover.xml"/>
<arg value="${builddir}/logs/coverage/"/>
</exec>
<exec executable="${vendorbindir}/phpcov">
<arg value="merge"/>
<arg value="--html=${builddir}/coverage/html"/>
<arg value="${builddir}/logs/coverage/"/>
</exec>
</target>
<target name="composer" description="Run Composer" depends="composer-check,composer-install,composer-update,composer-show" unless="composer.executed">
<property name="composer.executed" value="true"/>
</target>
<target name="get-composer" description="Get Composer" unless="composer.exists">
<mkdir dir="${vendorbindir}"/>
<get dest="${vendorbindir}" skipexisting="true">
<url url="https://getcomposer.org/composer.phar"/>
</get>
<available file="${composerbinfile}" property="composer.exists"/>
</target>
<target name="composer-check" description="Check Composer" depends="get-composer">
<exec executable="php" failonerror="true" dir="${composerdir}">
<arg value="${composerbinfile}"/>
<arg value="self-update"/>
</exec>
<exec executable="php" failonerror="true" dir="${composerdir}" outputproperty="vendorbindir">
<arg value="${composerbinfile}"/>
<arg value="config"/>
<arg value="bin-dir"/>
</exec>
</target>
<target name="composer-install" description="Run Composer install" depends="get-composer" unless="composer.lock.exists">
<exec executable="php" failonerror="true" dir="${composerdir}">
<arg value="${composerbinfile}"/>
<arg value="install"/>
<arg value="--prefer-dist"/>
</exec>
<available file="${composerdir}/composer.lock" property="composer.lock.exists"/>
</target>
<target name="composer-update" description="Run Composer update" depends="get-composer" if="composer.lock.exists">
<exec executable="php" failonerror="true" dir="${composerdir}">
<arg value="${composerbinfile}"/>
<arg value="update"/>
<arg value="--prefer-dist"/>
</exec>
<available file="${composerdir}/composer.lock" property="composer.lock.exists"/>
</target>
<target name="composer-show" description="Run Composer show" depends="get-composer,composer-show-config" if="composer.lock.exists">
<exec executable="php" failonerror="true" dir="${composerdir}" outputproperty="output-composer-show">
<arg value="${composerbinfile}"/>
<arg value="show"/>
</exec>
<echo message="${output-composer-show}"/>
</target>
<target name="composer-show-config" description="Show composer config settings" depends="get-composer">
<exec executable="php" failonerror="true" dir="${composerdir}" outputproperty="output-composer-config">
<arg value="${composerbinfile}"/>
<arg value="config"/>
<arg value="--list"/>
</exec>
<echo message="${output-composer-config}"/>
</target>
<target name="phpcb" depends="composer" description="Aggregate tool output with PHP_CodeBrowser" if="drupal.exists">
<exec executable="${vendorbindir}/phpcb">
<arg value="--log"/>
<arg path="${builddir}/logs"/>
<arg value="--source"/>
<arg path="${drupalmodules}"/>
<arg value="--output"/>
<arg path="${builddir}/code-browser"/>
</exec>
</target>
<target name="drupal-core" depends="composer" description="Download Drupal via Drush" unless="drupal.exists">
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}/..">
<arg value="-y"/>
<arg value="dl"/>
<arg value="drupal-7"/>
</exec>
<dirset dir="${basedir}" includes="drupal-7.*" id="drupaldir"/>
<fail message="Multiple or zero Drupal directories found: ${toString:drupaldir}!">
<condition>
<not>
<resourcecount refid="drupaldir" when="equal" count="1"/>
</not>
</condition>
</fail>
<symlink link="${basedir}/${drupalroot}" resource="${toString:drupaldir}" overwrite="true"/>
<available file="${basedir}/${drupalroot}/index.php" property="drupal.exists"/>
</target>
<target name="drupal-install" description="Install Drupal" depends="composer,drupal-core,database-configure,database-drop" unless="drupal.settings.exists">
<echo message="Running site install against Drupal"/>
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}">
<arg value="site-install"/>
<arg value="-y"/>
<arg value="minimal"/>
<arg value="--account-name=${admin.user}"/>
<arg value="--account-pass=${admin.pass}"/>
<arg value="--db-url=${db.url}"/>
</exec>
<chmod file="${basedir}/${drupalroot}/sites/default/settings.php" perm="+rw" type="file"/>
<chmod file="${basedir}/${drupalroot}/sites/default" perm="+rwx" type="dir"/>
</target>
<target name="enable-bdd-code-coverage" depends="drupal-setup" description="Drush to enable code_coverage module to allow its capture during BDD tests">
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}">
<arg value="-y"/>
<arg value="en"/>
<arg value="code_coverage"/>
</exec>
</target>
<target name="php-webserver-start" description="Start a simple webserver for PHP files" depends="drupal-setup">
<exec executable="${scriptsdir}/start_php_web.sh" dir="${basedir}/${drupalroot}" spawn="true">
</exec>
</target>
<target name="php-webserver-stop" description="Stop a simple webserver for PHP files">
<exec executable="${scriptsdir}/stop_php_web.sh" dir="${basedir}/${drupalroot}" spawn="true">
</exec>
</target>
<target name="phantomjs-start" description="Start a phantomjs">
<exec executable="${scriptsdir}/start_phantomjs.sh" dir="${scriptsdir}" spawn="true">
</exec>
</target>
<target name="phantomjs-stop" description="Stop a phantomjs">
<exec executable="${scriptsdir}/stop_phantomjs.sh" dir="${scriptsdir}" spawn="true">
</exec>
</target>
<target name="webserver-start" description="Start a simple webserver for json files">
<exec executable="${scriptsdir}/start_web.sh" dir="${scriptsdir}" spawn="true">
</exec>
</target>
<target name="webserver-stop" description="Stop a simple webserver for json files">
<exec executable="${scriptsdir}/stop_web.sh" dir="${scriptsdir}" spawn="true">
</exec>
</target>
<target name="database-configure" description="Configure settings.local.php file" if="settings.local.php.exists">
<copy file="${basedir}/${drupalroot}/sites/default/example.settings.local.php" tofile="${basedir}/${drupalroot}/sites/default/settings.local.php" overwrite="yes"/>
<exec executable="ex" failonerror="true" dir="${basedir}/${drupalroot}">
<arg value="${basedir}/${drupalroot}/sites/default/settings.local.php"/>
<arg value="+%s/'database'.*=>.*'\zs.*\ze'/${db.name}/"/>
<arg value="+%s/'username'.*=>.*'\zs.*\ze'/${db.user}/"/>
<arg value="+%s/'password'.*=>.*'\zs.*\ze'/${db.pass}/"/>
<arg value="+%s/'host'.*=>.*'\zs.*\ze'/${db.host}/"/>
<arg value="-scwq!"/>
</exec>
<available file="${basedir}/${drupalroot}/sites/default/settings.local.php" property="settings.local.php.exists"/>
</target>
<target name="drupal-setup" description="Setup Drupal installation" depends="composer,drupal-core,database-setup" unless="drupal.settings.exists">
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}">
<arg value="status"/>
</exec>
</target>
<target name="database-setup" description="Setup the database" if="drupal.exists" depends="database-import,drupal-install">
</target>
<target name="database-import" description="Import the database" if="drupaldbfile.exists" depends="composer,drupal-core,database-configure,database-drop">
<exec executable="bash" failonerror="true" dir="${basedir}/${drupalroot}" input="${drupaldbfile}">
<arg value="-c"/>
<arg value="`${vendorbindir}/drush sql-connect`"/>
</exec>
</target>
<target name="database-drop" description="Clean the database" if="drupaldbfile.exists">
<exec executable="${vendorbindir}/drush" failonerror="true" dir="${basedir}/${drupalroot}">
<arg value="sql-drop"/>
<arg value="--yes"/>
</exec>
</target>
<target name="web-service-start" description="Start the web service" if="webservicename">
<exec executable="${scriptsdir}/start_service.sh" dir="${scriptsdir}" spawn="true">
<arg value="${webservicename}"/>
<if>
<not>
<equals arg1="${webservicerouterfile}" arg2=""/>
<then>
<arg value="${webservicerouterfile}"/>
</then>
</not>
</if>
</exec>
</target>
<target name="web-service-stop" description="Stop the web service" if="webservicename">
<exec executable="${scriptsdir}/stop_service.sh" dir="${basedir}" spawn="true">
<arg value="${webservicename}"/>
</exec>
</target>
<target name="combine-junit-xml" description="Combine JUnits xml results files into a single for using on other apps.">
<copy file="${builddir}/coverage/combined_clover.xml" todir="${builddir}/logs" failonerror="false"/>
<fileset id="fileset" dir="${builddir}/behat">
<include name="*.xml"/>
</fileset>
<pathconvert refid="fileset" property="converted" pathsep=" "/>
<exec executable="${composerdir}/merge_junit_results.py" output="${builddir}/logs/junit/combined_junit.xml" failonerror="false">
<env key="PATH" value="/opt/rh/python27/root/usr/bin:${env.PATH}"/>
<env key="LD_LIBRARY_PATH" value="/opt/rh/python27/root/usr/lib64:${env.LD_LIBRARY_PATH}"/>
<arg line="${converted}"/>
</exec>
<copy file="${builddir}/logs/junit.xml" todir="${builddir}/logs/junit" failonerror="false"/>
<exec executable="${vendorbindir}/phpjunitmerge" failonerror="false">
<arg value="${builddir}/logs/junit"/>
<arg value="${builddir}/logs/combined_junit.xml"/>
</exec>
</target>
<!-- Drupal targets -->
<target name="drupal-build" depends="drupal-install,modules-enable-contrib,modules-enable-custom,modules-enable-features,drush-composer"/>
<target name="drush-composer" description="Drush to install composer dependencies" if="drupal.exists" depends="composer,drupal-setup">
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}">
<arg value="-y"/>
<arg value="en"/>
<arg value="composer_manager"/>
</exec>
<exec executable="${vendorbindir}/drush" dir="${basedir}/${drupalroot}">
<arg value="composer-json-rebuild"/>
<arg value="--no-dev"/>
<arg value="-o"/>
</exec>
<exec executable="php" dir="${composerdir}">
<env key="COMPOSER_VENDOR_DIR" value="${drupalroot}/${drupallibraries}/composer"/>
<env key="COMPOSER" value="${drupalroot}/${drupalfiles}/composer/composer.json"/>
<arg value="${composerbinfile}"/>
<arg value="update"/>
<arg value="--no-dev"/>
<arg value="--prefer-source"/>
<arg value="-o"/>
</exec>
<exec executable="php" dir="${composerdir}">
<env key="COMPOSER_VENDOR_DIR" value="${drupalroot}/${drupallibraries}/composer"/>
<env key="COMPOSER" value="${drupalroot}/${drupalfiles}/composer/composer.json"/>
<arg value="${composerbinfile}"/>
<arg value="dump-autoload"/>
</exec>
</target>
<target name="modules-enable-contrib" description="Enables Drupal contrib modules." if="contrib.txt.exists">
<antcall target="modules-enable">
<param name="file" value="${contrib.txt.exists}"/>
</antcall>
</target>
<target name="modules-enable-custom" description="Enables Drupal custom modules." if="custom.txt.exists">
<antcall target="modules-enable">
<param name="file" value="${custom.txt.exists}"/>
</antcall>
</target>
<target name="modules-enable-devel" description="Enables Drupal development modules." if="devel.txt.exists">
<antcall target="modules-enable">
<param name="file" value="${devel.txt.exists}"/>
</antcall>
</target>
<target name="modules-enable-features" description="Enables Drupal features modules." if="features.txt.exists">
<antcall target="modules-enable">
<param name="file" value="${features.txt.exists}"/>
</antcall>
</target>
<target name="modules-enable" depends="drupal-setup" description="Runs Drush to enable modules listed in the file.">
<exec executable="bash" dir="${drupalroot}">
<env key="PATH" value="${env.PATH}:${vendorbindir}"/>
<arg value="-c"/>
<arg value="cat ${file} | xargs drush -y en"/>
</exec>
</target>
<target name="drupal-settings-check">
<available file="${basedir}/${drupalroot}/sites/default/settings.php" property="settings.php.exists"/>
</target>
<target name="drupal-settings-remove" depends="drupal-settings-check" if="settings.php.exists">
<delete file="${drupalroot}/sites/${drupalsite}/settings.php"/>
</target>
</project>