forked from oswaldderiemaecker/subsite-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.package.xml
334 lines (307 loc) · 14.8 KB
/
build.package.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
<?xml version="1.0" encoding="UTF-8" ?>
<project name="My subsite" default="help">
<!-- Delete the previous development build. -->
<target name="delete-dev">
<!--
During the Drupal installation process the settings folder is write
protected. Ensure it is writeable so it can be removed.
-->
<phingcall target="unprotect-folder">
<property name="folder.to.unprotect" value="${platform.build.settings.dir}" />
</phingcall>
<echo msg="Delete previous build." />
<phingcall target="delete-folder">
<property name="folder.to.delete" value="${platform.build.dir}" />
</phingcall>
</target>
<!-- Delete the previous distribution build. -->
<target name="delete-dist">
<echo msg="Delete previous build." />
<phingcall target="delete-folder">
<property name="folder.to.delete" value="${dist.build.dir}" />
</phingcall>
</target>
<!-- Delete a given folder. -->
<target name="delete-folder">
<!-- Use the faster native command on UNIX systems. -->
<if>
<os family="unix" />
<then>
<echo msg='rm -rf "${folder.to.delete}"' />
<exec
command='rm -rf "${folder.to.delete}"'
dir="${project.basedir}"
passthru="true"
checkreturn="true"
/>
</then>
<else>
<delete dir="${folder.to.delete}" includeemptydirs="true" failonerror="false" />
</else>
</if>
</target>
<!-- Make the given folder writeable. -->
<target name="unprotect-folder">
<!-- This should only be used on folders that need to be removed. -->
<if>
<available file="${folder.to.unprotect}" type="dir" />
<then>
<chmod mode="0777" failonerror="true" verbose="false" quiet="true">
<fileset dir="${folder.to.unprotect}" />
</chmod>
</then>
</if>
</target>
<!-- Copies a given folder to a new location. -->
<target name="copy-folder">
<copy todir="${copy.destination.path}" haltonerror="${copy.path.haltonerror}">
<fileset dir="${copy.source.path}" defaultexcludes="false" />
</copy>
</target>
<!-- Generate the makefile used to download development modules. -->
<target name="generate-development-makefile">
<echo msg="Generate the makefile for development modules." />
<if>
<available file="${subsite.temporary.development.make}" type="file" property="development.makefile.available" />
<then>
<echo message="Deleting existing makefile." />
<delete file="${subsite.temporary.development.make}" failonerror="false" />
</then>
</if>
<drushmakefile
makeFile="${subsite.temporary.development.make}"
coreVersion="${drupal.core.version}"
projects="${development.modules.download}"
defaultProjectDir="${development.modules.location}"
/>
</target>
<!-- Download development modules. -->
<target name="download-development-modules" depends="generate-development-makefile">
<echo msg="Download development modules." />
<phingcall target="drush-make-no-core">
<property name="drush.make.target.file" value="${subsite.temporary.development.make}" />
<property name="drush.make.root" value="${platform.build.dir}" />
</phingcall>
</target>
<!-- Make the development version of the subsite. -->
<target name="make-dev" depends="unpack-platform">
<echo msg="Make the subsite." />
<phingcall target="drush-make-no-core">
<property name="drush.make.target.file" value="${subsite.make}" />
<property name="drush.make.root" value="${platform.build.dir}" />
</phingcall>
</target>
<!-- Make the distribution version of the subsite. -->
<target name="make-dist">
<echo msg="Delete temporary build folder." />
<phingcall target="delete-folder">
<property name="folder.to.delete" value="${phing.project.tmp.dir}/build" />
</phingcall>
<echo msg="Make the subsite." />
<!--
Drush make builds the site as if it is part of a complete Drupal
installation. The actual build is in the /sites/all subfolder. Build
in a temporary folder and move the subsite into place when done.
-->
<phingcall target="drush-make-no-core">
<property name="drush.make.target.file" value="${subsite.make}" />
<property name="drush.make.root" value="${phing.project.tmp.dir}/build" />
</phingcall>
<!-- Move the subsite to its destination. -->
<echo msg='mv "${phing.project.tmp.dir}/build/sites/all/" "${dist.build.dir}"' />
<exec
command='mv "${phing.project.tmp.dir}/build/sites/all/" "${dist.build.dir}"'
dir="${project.basedir}"
passthru="true"
checkreturn="true"
/>
<echo msg="Clean up temporary build folder." />
<phingcall target="delete-folder">
<property name="folder.to.delete" value="${phing.project.tmp.dir}/build" />
</phingcall>
</target>
<!-- Subtarget: execute a makefile with the no-core option. -->
<target name="drush-make-no-core">
<echo message="Running make file ${drush.make.target.file} into folder ${drush.make.root}." />
<drush
command="make"
assume="yes"
bin="${drush.bin}"
pipe="yes"
verbose="${drush.verbose}"
root="${drush.make.root}">
<param>${drush.make.target.file}</param>
<param>${drush.make.root}</param>
<!--
Increasing the concurrency improves the build time by a factor
of 3.
-->
<option name="concurrency">10</option>
<option name="no-patch-txt"></option>
<!--
This option will allow us to build inside an existing folder.
-->
<option name="no-core"></option>
</drush>
</target>
<!-- Symlink the source folders for easy development. -->
<target name="link-dev-resources">
<!-- Symlink our custom modules. -->
<symlink link="${platform.build.subsite.modules.custom.dir}" target="${subsite.resources.modules.dir}" />
<!-- Symlink our custom features. -->
<symlink link="${platform.build.subsite.modules.features.dir}" target="${subsite.resources.features.dir}" />
<!-- Symlink our custom themes. Delete the empty folder which is created during Drush make. -->
<delete dir="${platform.build.subsite.themes.dir}" includeemptydirs="true" failonerror="false" />
<symlink link="${platform.build.subsite.themes.dir}" target="${subsite.resources.themes.dir}" />
<!-- Symlink our custom PSR-4 code. -->
<symlink link="${platform.build.subsite.source.dir}" target="${subsite.resources.source.dir}" />
<!-- Symlink composer configuration. -->
<symlink link="${platform.build.subsite.composer.json}" target="${subsite.resources.composer.json}" />
<symlink link="${platform.build.subsite.composer.lock}" target="${subsite.resources.composer.lock}" />
<!-- Symlink Behat binary and test directory from platform build. -->
<!-- See https://webgate.ec.europa.eu/CITnet/jira/browse/NEXTEUROPA-11706 for more information. -->
<symlink link="bin/behat" target="${platform.build.dir}/vendor/bin/behat" overwrite="true"/>
<symlink link="${platform.build.dir}/tests" target="${project.basedir}/tests" overwrite="true"/>
</target>
<!-- Copy subsite resources into the build folder. -->
<target name="copy-dist-resources">
<echo msg="Copy custom resources." />
<!-- Copy our custom modules. -->
<phingcall target="copy-folder">
<property name="copy.source.path" value="${subsite.resources.modules.dir}" />
<property name="copy.destination.path" value="${dist.build.modules.custom.dir}" />
<property name="copy.path.haltonerror" value="false" override="true"/>
</phingcall>
<!-- Copy our custom features. -->
<phingcall target="copy-folder">
<property name="copy.source.path" value="${subsite.resources.features.dir}" />
<property name="copy.destination.path" value="${dist.build.modules.features.dir}" />
<property name="copy.path.haltonerror" value="false" override="true"/>
</phingcall>
<!-- Copy our custom themes. -->
<phingcall target="copy-folder">
<property name="copy.source.path" value="${subsite.resources.themes.dir}" />
<property name="copy.destination.path" value="${dist.build.themes.dir}" />
<property name="copy.path.haltonerror" value="false" override="true"/>
</phingcall>
<!-- Copy our custom PSR-4 code. -->
<phingcall target="copy-folder">
<property name="copy.source.path" value="${subsite.resources.source.dir}" />
<property name="copy.destination.path" value="${dist.build.source.dir}" />
<property name="copy.path.haltonerror" value="false" override="true"/>
</phingcall>
<!-- Copy composer configuration. -->
<copy todir="${dist.build.dir}" file="${subsite.resources.composer.json}" />
<copy todir="${dist.build.dir}" file="${subsite.resources.composer.lock}" />
</target>
<!-- Install Composer dependencies for the build system. -->
<target name="install-build-dependencies">
<composer command="install" composer="${composer.bin}">
<arg value="--working-dir=${project.basedir}" />
</composer>
</target>
<!-- Install Composer dependencies for the subsite. -->
<target name="install-dev-dependencies">
<composer command="install" composer="${composer.bin}">
<arg value="--working-dir=${platform.build.subsite.dir}" />
</composer>
</target>
<!-- Install Composer development dependencies for the platform. -->
<!-- Note: this is a temporary workaround until we get Composer to work properly with sub-sites. -->
<!-- See https://webgate.ec.europa.eu/CITnet/jira/browse/NEXTEUROPA-11706 for more information. -->
<target name="install-platform-dev-dependencies">
<composer command="install" composer="${composer.bin}">
<arg value="--working-dir=${platform.build.dir}" />
</composer>
</target>
<!-- Link site document root to Webserver document root. -->
<target
name="link-docroot"
description="Create a symlink from the build folder to the webserver document root.">
<symlink link="${server.docroot}" target="${platform.build.dir}" overwrite="true" />
</target>
<!-- Update .htaccess. -->
<target name="update-htaccess">
<if>
<istrue value="${drupal.htaccess.append.text}" />
<then>
<append destfile="${drupal.htaccess.path}" text="${drupal.htaccess.append.text}" />
</then>
</if>
</target>
<!-- Download the platform. -->
<target name="download-platform">
<!--
The platform is very large so downloading it can take a long time.
Only download it when it hasn't yet been downloaded.
-->
<if>
<not>
<available file="${platform.package.tarball}" type="file" />
</not>
<then>
<!-- Create the destination directory if it doesn't exist. -->
<mkdir dir="${platform.package.destination}" />
<echo msg="Starting to download the platform. Depending on your connection this can take between 5-15 minutes. Go get some coffee." />
<echo msg="This file will only be downloaded once and will be cached in ${platform.package.tarball}." />
<echo msg="You can delete this cached file whenever you want to download a new version of the platform." />
<continuousphp-config token="${platform.package.token}" />
<continuousphp-package
provider="${platform.package.provider}"
repository="${platform.package.repository}"
reference="${platform.package.reference}"
destination="${platform.package.destination}"
property="platform.package.property"
/>
<echo msg="Downloaded platform package reference ${platform.package.property}" />
</then>
<else>
<echo msg="Skipping platform download, it is already downloaded at ${platform.package.tarball}. Delete this file if you want to download the latest version." />
</else>
</if>
</target>
<!-- Unpack the platform. -->
<target name="unpack-platform" depends="download-platform">
<!-- Use the faster native commands on UNIX systems. -->
<if>
<os family="unix" />
<then>
<echo msg='mkdir "${platform.build.dir}"' />
<exec
command='mkdir "${platform.build.dir}"'
dir="${project.basedir}"
passthru="true"
/>
<echo msg='tar xzf "${platform.package.tarball}" -C "${platform.build.dir}"' />
<exec
command='tar xzf "${platform.package.tarball}" -C "${platform.build.dir}"'
dir="${project.basedir}"
passthru="true"
checkreturn="true"
/>
</then>
<else>
<untar file="${platform.package.tarball}" todir="${platform.build.dir}" />
</else>
</if>
</target>
<target
name="build-dev"
description="Build a local development version of the subsite."
depends="install-build-dependencies, delete-dev, make-dev, link-dev-resources, install-platform-dev-dependencies, install-dev-dependencies, setup-behat, update-htaccess, setup-files-directory, setup-php-codesniffer, download-development-modules, build-custom"
/>
<target
name="build-dist"
description="Build a version of the subsite intended to distribute as a release package."
depends="install-build-dependencies, delete-dist, make-dist, copy-dist-resources, build-custom"
/>
<!-- Setup file directory -->
<target name="setup-files-directory">
<if>
<istrue value="${platform.build.files.dir}" />
<then>
<mkdir dir="${platform.build.files.dir}/private_files" />
</then>
</if>
</target>
</project>