-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.xml
290 lines (238 loc) · 13.6 KB
/
install.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
<?xml version="1.0"?>
<!--
@file install.xml
Targets for installing the-build templates into a project.
Copyright 2016, 2017, 2018 Palantir.net, Inc.
-->
<project name="install" default="install">
<!-- This is required to set ${composer.composer} for installing for Platform.sh -->
<import file="the-build.xml" />
<property name="build.dir" value="${application.startdir}" />
<property name="build.env" value="default" />
<basename property="projectname" file="${build.dir}" suffix="local" />
<resolvepath file="${phing.dir.install}/../" propertyName="build.thebuild.dir" />
<!-- Provide the <copyproperties /> task. -->
<taskdef name="copyproperties" classname="TheBuild\CopyPropertiesTask" />
<!-- Target: install -->
<target name="install" description="Install the Phing build template into your project.">
<!-- Configuration prompts.
This creates the initial project properties file.
-->
<echo message="Configure the default environment..." />
<!-- Use existing configuration first (e.g. reinstalling the-build) -->
<if>
<available file="${application.startdir}/.the-build/build.yml" />
<then>
<property file="${application.startdir}/.the-build/build.yml" prefix="default" />
</then>
</if>
<!-- ... then load the defaults. -->
<property file="${build.thebuild.dir}/defaults.yml" prefix="default" />
<mkdir dir="${application.startdir}/.the-build" />
<!-- Generate a hash salt for Drupal. -->
<php expression="hash('sha256', print_r($_SERVER, TRUE))" returnProperty="hash_salt" />
<mkdir dir="${application.startdir}/config" />
<echo message="${hash_salt}" file="${application.startdir}/config/salt.txt" />
<!-- Prompt for the site name. -->
<propertyprompt propertyName="projectname.new" defaultValue="${projectname}" promptText="Machine name for this project" promptCharacter=":" />
<property name="projectname" value="${projectname.new}" override="true" />
<!-- Prompt for the Drupal URI. -->
<property name="default.drupal.sites.default.uri" value="https://${projectname}.ddev.site" />
<propertyprompt propertyName="drupal.sites.default.uri" defaultValue="${default.drupal.sites.default.uri}" promptText="Drupal URI" promptCharacter=":" />
<!-- Prompt for the web host. -->
<input propertyName="build.host" validArgs="acquia,pantheon,platformsh,other" message="Hosting platform" promptChar=":" />
<!-- Set and prompt for additional properties based on the host. We're not going
very deep here at the moment because there are several elements of the setup
that can vary, especially around the host-specific settings.php files. -->
<switch value="${build.host}">
<case value="acquia">
<property name="drupal.root" value="docroot" override="true" />
</case>
<case value="pantheon">
<property name="drupal.root" value="web" override="true" />
</case>
<case value="platformsh">
<property name="drupal.root" value="web" override="true" />
</case>
<default>
<property name="drupal.root" value="web" override="true" />
</default>
</switch>
<!-- Load the defaults into the global namespace, which won't overwrite the properties the user just set. -->
<property file="${build.thebuild.dir}/defaults.yml" />
<!-- Copy defaults to fill in the sites array. -->
<copyproperties fromPrefix="drupal.sites._defaults" toPrefix="drupal.sites.default" override="false" />
<!-- Write the default properties file. -->
<copy file="${phing.dir.install}/../defaults/install/the-build/build.yml" tofile="${application.startdir}/.the-build/build.yml" overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<phingcall target="setup-web-root" />
<phingcall target="setup-templates" />
<phingcall target="setup-host" />
<!-- Run the first build. -->
<phing dir="${application.startdir}" target="build" inheritAll="false" />
<!-- If Drupal has a database connection available, offer to install Drupal. -->
<trycatch>
<try>
<!-- The 'haltonfailure' attribute seems to have the opposite behavior
from what is described in the Phing documentation. -->
<phing dir="${application.startdir}" target="drupal-has-database-connection" inheritAll="false" haltonfailure="true" />
<!-- This code will run only when a database connection is available. -->
<input propertyName="install_now" validArgs="y,n" message="Install Drupal now " promptChar="?" />
<if>
<equals arg1="${install_now}" arg2="y" />
<then>
<phing dir="${application.startdir}" target="drupal-first-install" inheritAll="false" />
</then>
</if>
</try>
<catch>
<!-- Drupal will be installed later, if not manually then by the 'install'
target in the default build.xml. -->
<echo>Skipping Drupal installation, since the database is not available.
From within a development environment, you can run `phing install` to install Drupal.
</echo>
</catch>
</trycatch>
<!-- Whitespace is intentional. -->
<echo>
Successfully installed the-build. Next, you may want to run:
$> phing list
$> phing install
$> phing test</echo>
</target>
<!-- Target: setup-web-root
If the drupal.root directory doesn't exist, then we need to move it from the other location (web /
docroot).-->
<target name="setup-web-root" depends="set-site">
<available file="${build.dir}/${drupal.root}/core" type="dir" property="drupal.root.exists" value="true" />
<if>
<not><equals arg1="${drupal.root.exists}" arg2="1" /></not>
<then>
<!-- The one that's available is the location we're moving from. -->
<available file="${build.dir}/web/core" type="dir" property="drupal.root.old" value="web" />
<available file="${build.dir}/docroot/core" type="dir" property="drupal.root.old" value="docroot" />
<echo msg="Moving the ${drupal.root.old}/ directory to ${drupal.root}/" />
<exec command="rm -rf ${drupal.root}" dir="${build.dir}" />
<exec command="mv ${drupal.root.old} ${drupal.root}" dir="${build.dir}" checkreturn="true" logoutput="true" />
<echo msg="Editing your composer.json to install Drupal in ${drupal.root}/" />
<reflexive>
<fileset dir="${build.dir}" includes="composer.json" />
<filterchain>
<replaceregexp>
<regexp pattern='"${drupal.root.old}/(core|libraries|modules|profiles|themes)' replace='"${drupal.root}/\1' />
<regexp pattern='"web-root": "${drupal.root.old}/"' replace='"web-root": "${drupal.root}/"' />
</replaceregexp>
</filterchain>
</reflexive>
<echo msg="Updating your composer.lock hash" />
<exec command="composer update --lock" dir="${application.startdir}" />
</then>
</if>
</target>
<!-- Target: setup-templates -->
<target name="setup-templates" depends="set-site">
<!-- Set the project name in the ddev config. -->
<replaceregexp match="name: .*" replace="name: ${projectname}" file="${application.startdir}/.ddev/config.yaml" />
<!-- Copy the build file template.
This doesn't do any property substitution except for the "projectname",
which is the name of the install directory, and the "host", set by prompt
above.
We can't do general property substitution here because this is a phing
project file that uses phing variables.
-->
<copy file="${phing.dir.install}/../defaults/install/build.xml" tofile="${application.startdir}/build.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="projectname" value="${projectname}" />
<token key="host" value="${build.host}" />
</replacetokens>
</filterchain>
</copy>
<!-- Copy the phpcs.xml file template.
This doesn't do any property substitution except for the "projectname".
-->
<copy file="${phing.dir.install}/../defaults/install/phpcs.xml" tofile="${application.startdir}/phpcs.xml" overwrite="true">
<filterchain>
<replacetokens>
<token key="projectname" value="${projectname}" />
</replacetokens>
</filterchain>
</copy>
<!-- Copy other templates into place.
These copy commands use <expandproperties /> for property substitution.
-->
<!-- Copy the behat template. -->
<copy file="${phing.dir.install}/../defaults/install/behat.yml" tofile="${application.startdir}/behat.yml" overwrite="true">
<filterchain>
<expandproperties />
<!-- Sometimes behat has issues with HTTPS, especially when
using the php built-in webserver on CI. -->
<replaceregexp>
<regexp pattern="https:" replace="http:" />
</replaceregexp>
</filterchain>
</copy>
<!-- Copy the CircleCI configuration -->
<copy todir="${application.startdir}/" overwrite="true">
<fileset dir="${phing.dir.install}/../defaults/install" includes=".circleci/" />
<filterchain>
<expandproperties />
</filterchain>
</copy>
<!-- Copy the CircleCI properties. -->
<copy file="${phing.dir.install}/../defaults/install/the-build/build.circleci.yml" tofile="${application.startdir}/.the-build/build.circleci.yml" overwrite="true" />
<!-- Copy Drush configuration and aliases file templates. -->
<copy file="${phing.dir.install}/../defaults/install/drush/drush.yml" tofile="${application.startdir}/drush/drush.yml" overwrite="true">
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy file="${phing.dir.install}/../defaults/install/drush/sites/projectname.site.yml" tofile="${application.startdir}/drush/sites/${projectname}.site.yml" overwrite="true">
<filterchain>
<replacetokens>
<token key="uri" value="${drupal.sites.default.uri}" />
</replacetokens>
</filterchain>
</copy>
<!-- Set up the Drupal sites directory. -->
<property name="drupal.site.dir" value="default" />
<mkdir dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" />
<chmod mode="750" file="${build.dir}/${drupal.root}/sites/default/" />
<mkdir dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}/files" />
</target>
<!-- Target: setup-host -->
<target name="setup-host" depends="set-site" description="Add host-specific configuration files.">
<fail unless="build.host"/>
<switch value="${build.host}">
<case value="acquia">
<!-- Site-level setup -->
<!-- @see https://docs.acquia.com/cloud-platform/performance/memcached/enable/ -->
<httpget url="https://docs.acquia.com/_downloads/cloud-memcache-d8+.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}" filename="settings.acquia-memcache.php"/>
</case>
<case value="pantheon">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/pantheon.yml" todir="${application.startdir}" overwrite="true"/>
<!-- Site-level setup -->
<httpget url="https://raw.githubusercontent.com/pantheon-systems/drops-8/default/sites/default/settings.pantheon.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}"/>
</case>
<case value="platformsh">
<!-- Project-level setup -->
<copy file="${build.thebuild.dir}/defaults/install/.platform.app.yaml" todir="${application.startdir}" overwrite="true"/>
<copy todir="${application.startdir}/.platform" overwrite="true">
<fileset dir="${build.thebuild.dir}/defaults/install/.platform"/>
</copy>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/.environment" dir="${build.dir}/"/>
<!-- Site-level setup -->
<composer command="require" composer="${composer.composer}">
<arg line="--working-dir ${application.startdir}"/>
<arg value="platformsh/config-reader:^2.1"/>
</composer>
<httpget url="https://raw.githubusercontent.com/platformsh/template-drupal8/master/web/sites/default/settings.platformsh.php" dir="${build.dir}/${drupal.root}/sites/${drupal.site.dir}"/>
</case>
<default/>
</switch>
</target>
</project>