-
Notifications
You must be signed in to change notification settings - Fork 8
/
buildfile.xml
678 lines (607 loc) · 24.3 KB
/
buildfile.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
<?xml version="1.0" encoding="UTF-8"?>
<project>
<tstamp>
<format property="FULLDTIME" pattern="%Y%m%d%H%M%S" />
</tstamp>
<!-- Make sure properties are in existence -->
<available file="${project.basedir}/build/build.properties" property="properties_exist" />
<!-- Has the modules file been created? -->
<available file="${modules.depends.file}" property="modules_file_exists" />
<!-- have we been installed? -->
<available file="${project.basedir}/.env" property="installed" />
<!-- we need this first so that it's set BEFORE the properties file is read -->
<if>
<isset property="env.GIT_BRANCH" />
<then>
<property name="git.branch" value="${env.GIT_BRANCH}" />
</then>
</if>
<!-- if it's been set from environment, lets clean it up a little bit -->
<if>
<isset property="git.branch" />
<then>
<php expression="str_replace('origin/','', '${git.branch}')" returnProperty="git.branch"/>
</then>
</if>
<echo>${git.branch}</echo>
<property file="${project.basedir}/build/build.properties"></property>
<!-- To maintain backwards compatibility, we must default project.root to mysite, even if not
present in build.properties, since this used to be hardcoded. -->
<property name="project.root" value="mysite" />
<if>
<isset property="env.GIT_COMMIT" />
<then>
<property name="BUILD_STAMP" value="${env.GIT_COMMIT}" />
</then>
<else>
<property name="BUILD_STAMP" value="${DSTAMP}" />
</else>
</if>
<echo>Creating build ${BUILD_STAMP}</echo>
<!-- Load in the custom tasks -->
<taskdef name="symlink" classname="build.SymlinkTask" classpath="${project.basedir}" />
<taskdef name="copyfolders" classname="build.CopyFoldersTask" classpath="${project.basedir}" />
<taskdef name="sstest" classname="build.SilverStripeTestTask" classpath="${project.basedir}" />
<taskdef name="ssmodules" classname="build.LoadModulesTask" classpath="${project.basedir}" />
<taskdef name="sspatches" classname="build.ApplyPatchesTask" classpath="${project.basedir}" />
<taskdef name="ssdeploy" classname="build.SilverStripeDeployTask" classpath="${project.basedir}" />
<target name="help">
<echo>
Symbiote Project Build
------------------------------------
This build file contains targets to assist in creating new SilverStripe project builds.
* Delete the .git directory! You'll eventually add this project to a new location, meaning it is unnecessary to keep the existing git info
* Edit this build file and change the project name from rename-me to something more accurate
* Copy the build/build.properties.sample file to build/build.properties
* Edit that file and make any necessary adjustments. In particular, change the rewrite.base variable to match your webroot
* Edit the build/dependent-modules and add in any additional modules you may need. The format for these is
** modulename git|svn.url (the SCM url to retrieve this module) true|false (whether to run dev/build after fetching)
* Run phing, which will fetch all needed modules and run a dev/build for the first time
* Visit http://localhost/pathname/dev/build to ensure all caches are built correctly for the web
Important targets
* build - Retrieves all dependent modules (or updates them if they already exist), applies any relevant patches, and runs dev/build
* test - Executes all unit tests. You can run tests just for a single module by passing a module name, ie phing test -Dmodule=mysite. You can
also optionally pass a single test case to run, eg phing test -Dmodule=mysite -Dtestcase=MyTest
* phing-package - Creates a complete copy of this development environment repository that can be passed to another person, retaining all SVN and Git information
* update-package - Creates a package that excludes several diretories that can be used for extracting over the top of existing installs
* themes-package - Creates a package that contains only the themes dir. This will take the whole themes folder and not attempt to understand changes.
* backup - Takes a database dump of the site before packaging
Other features
* In some cases you will want to provide custom patches to dependent modules. As these can't be committed back to this project's repository,
a mechanism exists to include just the .patch diffs. Drop any diffs into build/patches, and these will be applied during the build target.
</echo>
</target>
<target name="init" depends="non_interactive,check_properties">
<mkdir dir="${build.output.dir}" />
</target>
<!-- Load modules where sensitive dependency exists -->
<target name="update_modules" depends="create_modules_file">
<if>
<available file="${modules.depends.file}.default" />
<then>
<ssmodules file="${modules.depends.file}" noninteractive="${ni_build}"/>
</then>
</if>
</target>
<!-- deprecated target; defers to base install target now -->
<target name="update-composer" depends="composer-install">
</target>
<target name="create_modules_file" unless="modules_file_exists">
<if>
<available file="${modules.depends.file}.default" />
<then>
<copy file="${modules.depends.file}.default" tofile="${modules.depends.file}" />
</then>
</if>
</target>
<!--
Add a new module to the system. Run from the commandline, you can pass
in the details of the module as phing add_module -Dmodule=blog -Dmodurl=http://path/to/svn
-->
<target name="add_module">
<ssmodules name="${module}" url="${modurl}" />
</target>
<!-- Ensures the build.properties file exists! -->
<target name="check_properties" unless="properties_exist">
<!-- create a default file only if it doesn't exist -->
<copy tofile="${project.basedir}/build/build.properties" file="${project.basedir}/build/build.properties.sample" />
<property file="${project.basedir}/build/build.properties"></property>
<!-- <fail>!!Please create the build/build.properties file before continuing!!</fail> -->
</target>
<!-- default config file set -->
<target name="default_configs" description="Ensure default configuration files are available">
<!-- Copy the DB configs -->
<if>
<not>
<os family="windows" />
</not>
<then>
<echo>Touching configs if they exist</echo>
<exec command="touch -c .env" checkreturn="true" />
<exec command="touch -c ${project.root}/_config/local.yml" checkreturn="true" />
<exec command="touch -c test-assist/artifacts/html/.htaccess" checkreturn="true" />
<exec command="touch -c .htaccess" checkreturn="true" />
</then>
</if>
<!-- with the following configs, we use the build/ base, but if there's a project specific
replacement, we use that -->
<property name="config_prefix" value="" />
<if>
<available file="${project.root}/${local.php.config}" />
<then>
<property name="config_prefix" value="${project.root}/" override="true" />
</then>
</if>
<echo>local.php prefix = ${config_prefix}</echo>
<if>
<not>
<available file=".env" />
</not>
<then>
<copy tofile=".env" file="${config_prefix}${local.php.config}" overwrite="false">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</then>
</if>
<property name="config_prefix" value="" override="true" />
<if>
<available file="${project.root}/${local.yml.config}" />
<then>
<property name="config_prefix" value="${project.root}/" override="true" />
</then>
</if>
<echo>local.yml prefix = ${config_prefix}</echo>
<copy tofile="${project.root}/_config/local.yml" file="${config_prefix}${local.yml.config}" overwrite="false">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<!-- set up the html report output dir with an htaccess -->
<if>
<not>
<available file="test-assist/artifacts/html/.htaccess" />
</not>
<then>
<mkdir dir="test-assist/artifacts/html" />
<echo file="test-assist/artifacts/html/.htaccess" append="false">
Allow from 127.0.0.1
</echo>
</then>
</if>
<property name="config_prefix" value="" override="true" />
<if>
<available file="${project.root}/${htaccess.config}" />
<then>
<property name="config_prefix" value="${project.root}/" override="true" />
</then>
</if>
<!-- Copy the htaccess - checking for public directory layout -->
<if>
<available file="public" type="dir" />
<then>
<exec command="touch -c public/.htaccess" checkreturn="true" />
<copy tofile="public/.htaccess" file="${config_prefix}${htaccess.config}" overwrite="false">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy tofile=".htaccess" file="${config_prefix}${htaccess-root-public.config}" overwrite="false" />
</then>
<else>
<copy tofile=".htaccess" file="${config_prefix}${htaccess.config}" overwrite="false">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</else>
</if>
</target>
<!-- A target that gets executed if the 'ni_build' parameter is set. This is done when
the build is executed from a CI container -->
<target name="non_interactive" if="ni_build">
<!-- we'll make sure that there's a build.properties file, even if we're just using the default -->
<delete file="${project.basedir}/build/build.properties" />
<copy tofile="${project.basedir}/build/build.properties" file="${project.basedir}/build/build.properties.sample" />
<delete dir="assets" />
<delete dir="public/assets" />
<delete file="${project.basedir}/.env" />
<delete file="${project.basedir}/${project.root}/_config/local.yml" />
<property name="properties_exist" value="true" override="true" />
<property file="${project.basedir}/build/build.properties"></property>
<mkdir dir="${project.basedir}/silverstripe-cache" />
</target>
<!-- Installs a freshly checked-out silverstripe project -->
<target name="build" depends="init,default_configs">
<echo file="${project.root}/BUILD_NUMBER" append="false">Build ${BUILD_STAMP}</echo>
<phingcall target="update-composer" />
<phingcall target="update_modules" />
<phingcall target="apply_patches" />
<!-- Trigger /dev/build for the new system -->
<echo>Running dev/build with flush and permission disabling</echo>
<exec command="php vendor/silverstripe/framework/cli-script.php dev/build flush=1 disable_perms=1" passthru="true" checkreturn="true" />
</target>
<target name="apply_patches">
<mkdir dir="${patches.dir}" />
<sspatches patchdir="${patches.dir}" />
<if>
<isset property="check_patches" />
<then>
<if>
<isset property="patches_applied" />
<then>
<fail>Patches already applied - this needs fixing</fail>
</then>
<else>
<echo message="Patches successful" />
</else>
</if>
</then>
</if>
</target>
<target name="pak">
<delete file="${project.root}/build/site.sspak" />
<exec command="sspak save . ${project.root}/build/site.sspak" passthru="true" />
</target>
<target name="unpak">
<exec command="sspak load ${project.root}/build/site.sspak ." passthru="true" />
</target>
<!-- Create a deployable package to use as the base for installing a new site FROM SCRATCH.
Please use the update-package target for creating a package to use for an update -->
<target name="package" depends="init">
<exec command="touch ${project.basedir}/.pkgignore" />
<property name="currentpackage" value="${build.output.dir}/${package.name}" />
<property name="packagetype" value="deploy" />
<phingcall target="archive-package" />
<tar destfile="${build.output.dir}/${package.name}" compression="gzip">
<fileset dir="${project.basedir}">
<include name="**/**" />
<exclude name="silverstripe-cache/" />
<exclude name="sitemap.xml" />
<exclude name="assets/**" />
<exclude name="public/assets/**" />
<exclude name="test-assist/" />
<exclude name="build/" />
<exclude name="build.xml" />
<exclude name="**/*.env" />
<exclude name=".gitlab-ci.yml" />
<exclude name="**/*dockerfile*" />
<exclude name="${project.root}/local.conf.php" />
<exclude name="${project.root}/_config/local.yml" />
<exclude name="${project.root}/db.conf.php" />
<exclude name="${project.root}/*.log" />
<exclude name="${project.root}/build/**" />
<exclude name="**/.svn/**" />
<exclude name="**/.git/**" />
<exclude name="nbproject/**" />
<exclude name="**/.gitignore" />
<exclude name=".htaccess" />
<exclude name="**/.project" />
<exclude name="**/.buildpath" />
<exclude name="**/.settings" />
<exclude name="phpunit.*" />
<exclude name="**/phpunit.*" />
<exclude name="phpcs.*" />
<exclude name="**/phpcs.*" />
<exclude name="*.neon"/>
<!-- Exclude root .neon config files (used by PHPStan) -->
<exclude name="**/*.neon"/>
<!-- Exclude all .neon files in subdirectories/modules (used by PHPStan) -->
<exclude name="**/*.rej" />
<exclude name="**/*.orig" />
<exclude name="**/README*" />
<exclude name="composer.phar" />
<exclude name="themes/**/node_modules/**" />
<exclude name="install.*" />
<exclude name="docker-compose.*" />
<exclude name="*.sh" />
<excludesfile name="${project.basedir}/.pkgignore" />
</fileset>
</tar>
</target>
<!-- a package that includes all items that the phing build normally downloads, which can
be just extracted over the top of whatever is pulled out of git. This preserves all the
.svn files for dependent modules etc -->
<target name="distro" depends="">
<property name="currentpackage" value="${build.output.dir}/${distro-package.name}" />
<property name="packagetype" value="dist" />
<phingcall target="archive-package" />
<tar destfile="${build.output.dir}/${distro-package.name}" compression="gzip">
<fileset dir="${project.basedir}">
<include name="**/**" />
<exclude name="sitemap.xml" />
<exclude name="silverstripe-cache/" />
<exclude name="build.xml" />
<exclude name="build/**" />
<exclude name="build/archive/**" />
<exclude name="nbproject/**" />
<exclude name="**/.project" />
<exclude name="**/.buildpath" />
<exclude name="**/.settings" />
<exclude name="**/.git/**" />
</fileset>
</tar>
<chmod file="${build.output.dir}/${distro-package.name}" mode="0664" />
</target>
<target name="gittest">
<echo>This thing ${git.branch}</echo>
</target>
<!-- a package that includes all items that the phing build normally downloads, which can
be just extracted over the top of whatever is pulled out of git. This preserves all the
.svn files for dependent modules etc -->
<target name="phing-package" depends="">
<property name="currentpackage" value="${build.output.dir}/${phing-package.name}" />
<property name="packagetype" value="development" />
<phingcall target="archive-package" />
<tar destfile="${build.output.dir}/${phing-package.name}" compression="gzip" defaultexcludes="false">
<fileset dir="${project.basedir}">
<include name="**/**" />
<exclude name="sitemap.xml" />
<exclude name="silverstripe-cache/" />
<exclude name="build/archive/**" />
<exclude name="nbproject/**" />
<exclude name="**/.project" />
<exclude name="**/.buildpath" />
<exclude name="**/.settings" />
</fileset>
</tar>
<chmod file="${build.output.dir}/${phing-package.name}" mode="0664" />
</target>
<!-- A package that doesn't include files that are commonly overridden
on remote sites -->
<target name="update-package">
<property name="currentpackage" value="${build.output.dir}/${update-package.name}" />
<property name="packagetype" value="update" />
<phingcall target="archive-package" />
<tar destfile="${build.output.dir}/${update-package.name}" compression="gzip" includeemptydirs="false">
<fileset dir="${project.basedir}">
<include name="**/**" />
<exclude name="sitemap.xml" />
<exclude name="${project.root}/db.conf.php" />
<exclude name="**/*.env" />
<exclude name=".gitlab-ci.yml" />
<exclude name="**/*dockerfile*" />
<exclude name="_ss_environment.php" />
<exclude name="${project.root}/local.conf.php" />
<exclude name="${project.root}/_config/local.yml" />
<exclude name="${project.root}/*.log" />
<exclude name="build/**" />
<exclude name="${project.root}/build/**" />
<exclude name="build.xml" />
<exclude name=".htaccess" />
<exclude name="**/.svn/**" />
<exclude name="nbproject/**" />
<exclude name="**/.project" />
<exclude name="**/.buildpath" />
<exclude name="**/.settings" />
<exclude name="**/.git/**" />
<exclude name="phpunit.*" />
<exclude name="**/phpunit.*" />
<exclude name="phpcs.*" />
<exclude name="**/phpcs.*" />
<exclude name="*.neon"/>
<!-- Exclude root .neon config files (used by PHPStan) -->
<exclude name="**/*.neon"/>
<!-- Exclude all .neon files in subdirectories/modules (used by PHPStan) -->
<exclude name="assets/**" />
<exclude name="public/assets/**" />
<exclude name="silverstripe-cache/" />
<exclude name="themes/**/node_modules/**" />
<exclude name="install.*" />
<exclude name="docker-compose.*" />
<exclude name="*.sh" />
</fileset>
</tar>
<chmod file="${build.output.dir}/${update-package.name}" mode="0664" />
</target>
<!-- A package that includes only the themes files -->
<target name="themes-package">
<property name="currentpackage" value="${build.output.dir}/${themes-package.name}" />
<property name="packagetype" value="themes" />
<phingcall target="archive-package" />
<tar destfile="${build.output.dir}/${themes-package.name}" compression="gzip">
<fileset dir="${project.basedir}">
<include name="**/themes**" />
</fileset>
</tar>
<chmod file="${build.output.dir}/${themes-package.name}" mode="0664" />
</target>
<target name="package-module">
<property name="currentpackage" value="${module.file}" />
<property name="packagetype" value="module" />
<phingcall target="archive-package" />
<echo file="${module.name}/BUILD_NUMBER" append="false">Build ${BUILD_STAMP}</echo>
<mkdir dir="${build.output.dir}" />
<delete file="${module.file}" />
<tar destfile="${module.file}" compression="gzip">
<fileset dir="${project.basedir}">
<include name="${module.name}/**" />
<exclude name="**/.svn/" />
<exclude name="**/.git/" />
</fileset>
</tar>
</target>
<!-- Creates a backup of the existing project, including the MySQL dump -->
<target name="backup">
<echo file="README.txt" append="false">
To restore this backup:
* Import the database file in backups/${phing.project.name}.sql
* Copy configs/silverstripe/.env.sample to .env
* Edit DB settings in .env as appropriate (typically, use MySQLDatabase as the db.type)
* Run 'php vendor/silverstripe/framework/cli-script.php dev/build'
</echo>
<mkdir dir="${backup.dir}" />
<echo file="${backup.dir}/.htaccess" append="false">
Deny from all
</echo>
<exec command="mysqldump -u${db.user} -p${db.pass} ${db.name} > ${backup.sql}" checkreturn="true" />
<phingcall target="package" />
</target>
<target name="ci_test" depends="build">
<!-- lets get rid of files that we don't want tested -->
<delete file="${project.basedir}/vendor/silverstripe/framework/tests/WebserverRoutingTest.php" />
<property name="flush" value="1" override="true" />
<property name="build" value="1" override="true" />
<phingcall target="test" />
</target>
<target name="start_selenium">
<if>
<not>
<available file="test-assist/selenium.jar" />
</not>
<then>
<exec command="curl http://selenium-release.storage.googleapis.com/2.45/selenium-server-standalone-2.45.0.jar -o test-assist/selenium.jar" passthru="true" checkreturn="true" />
</then>
</if>
<exec command="java -jar test-assist/selenium.jar -Ddummy-config=selenium_${phing.project.name}" spawn="true" checkreturn="true" />
</target>
<target name="kill_selenium">
<echo>Killing selenium in ${project.basedir}</echo>
<exec command="ps -ef | grep selenium_${phing.project.name} | grep -v grep | awk '{print $2}' | xargs kill " spawn="true" checkreturn="true" />
</target>
<target name="start_solr">
<echo>Executing solr in ${project.basedir}</echo>
<exec command="cd solr/solr && java -jar -Ddummy-config=solr_${phing.project.name} start.jar" spawn="true" checkreturn="true" />
</target>
<target name="kill_solr">
<echo>Killing solr in ${project.basedir}</echo>
<exec command="ps -ef | grep solr_${phing.project.name} | grep -v grep | awk '{print $2}' | xargs kill " spawn="true" checkreturn="true" />
</target>
<!-- Execute all the test cases -->
<target name="test" depends="default_configs">
<!-- Make sure the log directory exists -->
<mkdir dir="${testing.logdir}" />
<mkdir dir="assets" />
<if>
<not>
<available file="vendor/phpunit/phpunit/phpunit.php" />
</not>
<then>
<phingcall target="composer-install" />
</then>
</if>
<sstest module="${module}" testcase="${testcase}" flush="${flush}" build="${build}" coverage="${coverage}" />
</target>
<target name="archive-package">
<copy todir="${build.archive.dir}">
<fileset dir="${build.output.dir}">
<include name="*${packagetype}.${git.branch}*.tar.gz" />
</fileset>
</copy>
<!-- delete all similar files from the output -->
<delete>
<fileset dir="${build.output.dir}">
<include name="*${packagetype}.${git.branch}*.tar.gz" />
</fileset>
</delete>
</target>
<target name="deploy">
<if>
<isset property="deploy.incremental" />
<then>
<phingcall target="update-package" />
</then>
<else>
<phingcall target="package" />
</else>
</if>
<foreach list="${deploy.targets}" param="deptarget" target="deploy-target" />
</target>
<target name="deploy-target">
<if>
<isset property="deploy.incremental" />
<then>
<property name="deploy.package" value="${update-package.name}" />
</then>
<else>
<property name="deploy.package" value="${package.name}" />
</else>
</if>
<ssdeploy username="${deploy.${deptarget}.user}" password="${deploy.${deptarget}.pass}" pubkeyfile="${deploy.${deptarget}.pubkey}" privkeyfile="${deploy.${deptarget}.privkey}" host="${deploy.${deptarget}.host}" port="${deploy.${deptarget}.port}" ignoreerrors="${deploy.first}" incremental="${deploy.incremental}" localpath="${build.output.dir}" apppath="${project.root}" remotepath="${deploy.${deptarget}.path}" package="${deploy.package}" apachegroup="${deploy.${deptarget}.apache-group}" />
</target>
<target name="clean">
<mkdir dir="${build.output.dir}" />
<delete file="${database_dump.name}"></delete>
</target>
<target name="phpstan">
<!--
Example CLI use: `phing phpstan -Dphpstan.level=2`
-->
<if>
<available file="${project.basedir}/vendor/bin/phpstan" />
<then>
<property name="phpstan.installed" value="1" />
</then>
</if>
<if>
<available file="${project.basedir}/vendor/symbiote/silverstripe-phpstan" type="dir" />
<then>
<property name="phpstan.silverstripe_installed" value="1" />
</then>
</if>
<if>
<isset property="phpstan.debug"/>
<then>
<property name="phpstan.debug_cmd" value="--debug" />
</then>
<else>
<property name="phpstan.debug_cmd" value="" />
</else>
</if>
<if>
<not>
<isset property="phpstan.disabled"/>
</not>
<then>
<!-- Run PHPStan if installed -->
<if>
<isset property="phpstan.installed"/>
<then>
<if>
<isset property="phpstan.silverstripe_installed"/>
<then>
<!-- Default values -->
<if>
<not>
<isset property="phpstan.level" />
</not>
<then>
<property name="phpstan.level" value="2" />
</then>
</if>
<if>
<not>
<isset property="phpstan.dir" />
</not>
<then>
<property name="phpstan.dir" value="${project.root}" />
</then>
</if>
<!-- Run PHPStan -->
<exec executable="vendor/bin/phpstan" passthru="true" checkreturn="true">
<arg value="analyse" />
<arg line="${phpstan.dir}" />
<arg line="-c phpstan.neon" />
<arg line="-a vendor/symbiote/silverstripe-phpstan/bootstrap.php" />
<arg line="--error-format table" />
<arg line="--level ${phpstan.level}"/>
<arg line="${phpstan.debug_cmd}"/>
</exec>
</then>
<else>
<echo msg="PHPStan SilverStripe extension is not installed in this project and was not executed." />
</else>
</if>
</then>
<else>
<echo msg="PHPStan is not installed in this project and was not executed." />
</else>
</if>
</then>
<else>
<echo msg="PHPStan has been disabled via the 'phpstan.disabled' property." />
</else>
</if>
</target>
</project>