-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy paththe-build.xml
195 lines (154 loc) · 7.86 KB
/
the-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
<?xml version="1.0"?>
<!--
@file the-build.xml
Contains the-build's environment-specific property loading.
This file is included in the build.dist.xml template with:
<import file="vendor/palantirnet/the-build/targets/the-build.xml" />
Copyright 2016, 2017, 2018 Palantir.net, Inc.
-->
<project name="the-build" default="the-build">
<!-- Provide the <drush /> task. -->
<taskdef name="drush" classname="Drush\Task" />
<!-- Provide the <includeresource /> task. -->
<taskdef name="includeresource" classname="TheBuild\IncludeResourceTask" />
<!-- Provide the <foreachkey /> task. -->
<taskdef name="foreachkey" classname="TheBuild\ForeachKeyTask" />
<!-- Provide the <copyproperties /> task. -->
<taskdef name="copyproperties" classname="TheBuild\CopyPropertiesTask" />
<!-- Provide the <selectpropertykey /> task. -->
<taskdef name="selectpropertykey" classname="TheBuild\SelectPropertyKeyTask" />
<!-- Provide the <selectone /> task. -->
<taskdef name="selectone" classname="TheBuild\SelectOneTask" />
<!-- Alias the build directory to the Phing start directory. -->
<property name="build.dir" value="${application.startdir}" />
<!-- Provide the path to the-build's code for loading templates and defaults -->
<!-- Phing maps the project name "the-build" to "the_build". -->
<resolvepath file="${phing.dir.the_build}/../" propertyName="build.thebuild.dir" />
<!-- Use the PALANTIR_ENVIRONMENT env variable to set the build environment. -->
<if>
<isset property="env.PALANTIR_ENVIRONMENT" />
<then>
<property name="build.env" refid="env.PALANTIR_ENVIRONMENT" />
</then>
</if>
<!-- Provide a default build environment. -->
<property name="build.env" value="default" />
<!-- Use the THE_BUILD_SITE env variable to set the default site. -->
<if>
<isset property="env.THE_BUILD_SITE" />
<then>
<property name="build.site" refid="env.THE_BUILD_SITE" />
</then>
</if>
<!-- Load build properties from the project environment, the project defaults, and
finally from the-build's own defaults.
-->
<if>
<not><isset property="build.defaults_loaded" /></not>
<then>
<!-- Load the project's environment-specific properties. -->
<if>
<available file="${build.dir}/.the-build/build.${build.env}.yml" />
<then>
<property file="${build.dir}/.the-build/build.${build.env}.yml" />
</then>
</if>
<!-- Load the project's defaults. This may be loaded twice, but that
should not be a problem. -->
<property file="${build.dir}/.the-build/build.yml" />
<!-- Load the-build's global defaults. -->
<property file="${build.thebuild.dir}/defaults.yml" />
<!-- Prevent the-build from reloading properties. -->
<property name="build.defaults_loaded" value="true" />
</then>
</if>
<!-- Use the project directory name as the project name, if it's not configured. -->
<basename property="projectname" file="${build.dir}" suffix="local" />
<!-- Configure binaries to run depending on whether we're inside of ddev or out. -->
<property name="drush.bin" value="${build.dir}/vendor/bin/drush" />
<property name="behat.bin" value="${build.dir}/vendor/bin/behat" />
<!-- If this is a ddev project, and we're outside of ddev, run these commands within ddev. -->
<exec command="which ddev" returnProperty="which_ddev" />
<if>
<and>
<available file="${build.dir}/.ddev/config.yaml" />
<equals arg1="${which_ddev}" arg2="0" />
<not><isset property="env.IS_DDEV_PROJECT" /></not>
</and>
<then>
<property name="drush.bin" value="ddev drush" override="true" />
<property name="behat.bin" value="ddev . vendor/bin/behat" override="true" />
</then>
</if>
<!-- Configure the composer command, depending on whether `composer` or `composer.phar` is available. -->
<exec command="command -v composer" outputProperty="composer.path.composer" />
<exec command="command -v composer.phar" outputProperty="composer.path.composer_phar" />
<if>
<not><equals arg1="${composer.path.composer}" arg2="" /></not>
<then><property name="composer.composer" value="${composer.path.composer}" /></then>
</if>
<if>
<not><equals arg1="${composer.path.composer_phar}" arg2="" /></not>
<then><property name="composer.composer" value="${composer.path.composer_phar}" /></then>
</if>
<!--
Default target: the-build
This target is included only because the <project> tag requires it.
-->
<target name="the-build" hidden="true">
<echo>Hello! I'm the-build.</echo>
</target>
<!--
Target: set-site
Set properties for the current site in 'drupal.site.*'.
-->
<target name="set-site" hidden="true">
<!-- Use this custom task to figure out which site to build. -->
<selectpropertykey prefix="drupal.sites." omitKeys="_defaults" propertyName="build.site" message="Select a site to build:" />
<!-- Copy defaults in first. -->
<copyproperties fromPrefix="drupal.sites._defaults" toPrefix="drupal.site" override="true" />
<!-- Override defaults with any site-specific values. -->
<copyproperties fromPrefix="drupal.sites.${build.site}" toPrefix="drupal.site" override="true" />
<!-- Validate that required Drupal site properties are present. -->
<fail unless="drupal.site.dir" msg="The 'drupal.sites.${build.site}.dir' property must be set in order to run build targets." />
<fail unless="drupal.site.uri" msg="The 'drupal.sites.${build.site}.uri' property must be set in order to run build targets." />
<!-- Fill in defaults for Drupal site properties. -->
<property name="drupal.site.config_sync_directory" value="../config/sites/${drupal.site.dir}" />
<property name="drupal.site.database.database" value="${build.site}" />
<property name="drupal.site.settings.file_public_path" value="sites/${drupal.site.dir}/files" />
<property name="drupal.site.settings.file_private_path" value="../artifacts/private/${drupal.site.dir}" />
<property name="drupal.site.build.settings_dest" value="${drupal.root}/sites/${drupal.site.dir}/settings.build.php" />
<property name="drupal.site.build.services_dest" value="${drupal.root}/sites/${drupal.site.dir}/services.build.yml" />
<!-- Configure Drush -->
<property name="drush.uri" refid="drupal.site.uri" override="true" />
</target>
<!--
Target: sites-run
Run a Phing target against each configured Drupal multisite.
-->
<target name="sites-run" description="Run a target against all sites. Use -Dtarget=foo">
<fail unless="target" />
<foreachkey prefix="drupal.sites" omitKeys="_defaults" target="sites-run-target" keyParam="site_key" prefixParam="prefix" />
</target>
<!--
Target: sites-run-target
Utility target used by 'all-sites' above. Runs the specified
target in an isolated Phing environment.
-->
<target name="sites-run-target" hidden="true">
<fail unless="target" />
<fail unless="site_key" />
<echo msg="Running 'phing ${target} -Dbuild.site=${site_key}'" />
<phing target="${target}" dir="${build.dir}" inheritAll="false">
<property name="build.site" value="${site_key}" />
</phing>
</target>
<!--
Target: mkdir
Utility target to allow creating a list of directories with <foreach />.
-->
<target name="mkdir" hidden="true">
<echo msg="${dir}" />
<mkdir dir="${dir}" />
</target>
</project>