forked from boyanborisov/drupal_build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
397 lines (314 loc) · 16.7 KB
/
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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="drupal_build" default="build" phingVersion="2.6.1"
description="Drupal build.xml. It handels install and update of drupal projects and other common tasks">
<target name="build" depends="init"
description="Target will try to update the project or it will try to checkout it if the one does not exist">
</target>
<target name="init" depends="properties-load" unless="targets.init.done" hidden="true">
<!-- Include phing extensions -->
<includepath classpath="phing_ext" />
<taskdef name="drush" classname="DrushTask" />
<!-- Init project properties -->
<property name="project.tmp" value="${project.basedir}/tmp" />
<property name="project.www" value="${project.basedir}/www" />
<php function="time" returnProperty="project.timestamp" />
<!-- Init drush task properties -->
<property name="drush.root" value="${project.www}" />
<!-- Create working dirs -->
<mkdir dir="${project.basedir}/tmp" mode="0775" />
<mkdir dir="${project.basedir}/www" mode="0775" />
<property name="targets.init.done" value="true" />
</target>
<!-- Load property files -->
<target name="properties-load" unless="targets.properties-load.done" hidden="true">
<!-- By default use default properties file `build.default.properties` -->
<property file="${project.basedir}/build.default.properties" override="true" />
<!-- Allow override using `build.properties` in build file directory -->
<!-- Include the file after each standard properties file -->
<property file="${project.basedir}/build.properties" override="true" />
<!-- Allow override using `build.env.properties` in build file directory based on the environment -->
<property file="${project.basedir}/build.${project.env}.properties" override="true" />
<!-- Allow override using `build.properties` in build file directory -->
<!-- Include the file after each standard properties file -->
<property file="${project.basedir}/build.properties" override="true" />
<!-- Set property to prevent unnecessary additional invocations of this target -->
<property name="targets.properties-load.done" value="true" />
</target>
<target name="project-create" depends="init" unless="targets.project-create.done" description="Initialize a new project">
<phingcall target="clean" />
<!-- Create working dirs -->
<mkdir dir="${project.basedir}/tmp" mode="0775" />
<drush command="pm-download" assume="yes">
<option name="drupal-project-rename" value="www" />
<param>drupal</param>
</drush>
<mkdir dir="${project.www}/sites/all/modules/contrib" mode="0775" />
<touch file="${project.www}/sites/all/modules/contrib/README.txt" />
<mkdir dir="${project.www}/sites/all/modules/custom" mode="0775" />
<touch file="${project.www}/sites/all/modules/custom/README.txt" />
<mkdir dir="${project.www}/sites/all/modules/features" mode="0775" />
<touch file="${project.www}/sites/all/modules/features/README.txt" />
<chmod file="${project.www}/sites/default/default.settings.php" mode="0775" failonerror="true" />
<drush command="pm-download" assume="yes">
<param>devel</param>
</drush>
<drush command="pm-download" assume="yes">
<param>features</param>
</drush>
<drush command="pm-download" assume="yes">
<param>views ctools</param>
</drush>
<phingcall target="project-create-profile" />
<phingcall target="drushrc-create" />
<gitinit repository="${project.www}" gitPath="${system.git}" />
<gitcheckout repository="${project.www}" branchname="${drupal.repo_branch}" create="true" gitPath="${system.git}" />
<exec level="info" dir="${project.www}" checkreturn="true" passthru="true" command="${system.git} add ." />
<gitcommit repository="${project.www}" message="Init project" allFiles="true" gitPath="${system.git}" />
<exec level="info" dir="${project.www}" checkreturn="true" passthru="true"
command="${system.git} remote add origin ${drupal.repo_url}" />
<gitpush repository="${project.www}" refspec="${drupal.repo_branch}:${drupal.repo_branch}" destination="${drupal.repo_url}"
gitPath="${system.git}" />
<gitfetch repository="${project.www}" gitPath="${system.git}" all="true" />
<exec level="info" dir="${project.www}" checkreturn="true" passthru="true"
command="${system.git} branch --set-upstream-to=origin/${drupal.repo_branch} ${drupal.repo_branch}" />
<property name="targets.project-create.done" value="true" />
</target>
<target name="project-create-profile" depends="init" unless="targets.project-create-profile.done" description="Create a custom profile based on Standard Drupal profile">
<copy todir="${project.www}/profiles/${drupal.profile}">
<fileset dir="${project.www}/profiles/standard">
<include name="**" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="standard_" replace="${drupal.profile}_" />
</replaceregexp>
</filterchain>
</copy>
<move todir="${project.www}/profiles/${drupal.profile}">
<fileset dir="${project.www}/profiles/${drupal.profile}">
<include name="*" />
</fileset>
<mapper type="regexp" from="^standard.([a-z]+)$" to="${drupal.profile}.\1" />
</move>
<copy file="${project.basedir}/settings/propeople.info" tofile="${project.www}/profiles/${drupal.profile}/${drupal.profile}.info" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern="@@name@@" replace="${drupal.profile}" />
</replaceregexp>
</filterchain>
</copy>
<property name="targets.project-create-profile.done" value="true" />
</target>
<target name="clean" depends="init" unless="targets.clean.done" description="Clean all project files and directories">
<property name="clean.trash-folder" value="${system.tmp}/phing_clean_tmp_trash_${project.timestamp}" />
<mkdir dir="${clean.trash-folder}" mode="0775" />
<exec level="info" command="mv ${project.www} ${clean.trash-folder}" />
<exec level="info" command="mv ${project.tmp} ${clean.trash-folder}" />
<delete dir="${clean.trash-folder}" includeemptydirs="true" quiet="true" />
<property name="targets.clean.done" value="true" />
</target>
<target name="clean-tmp" depends="init" unless="targets.clean-tmp.done" description="Clean tmp project files and directories">
<property name="clean.trash-folder" value="${system.tmp}/phing_clean_tmp_trash_${project.timestamp}" />
<mkdir dir="${clean.trash-folder}" mode="0775" />
<exec level="info" command="mv ${project.tmp} ${clean.trash-folder}" />
<delete dir="${clean.trash-folder}" includeemptydirs="true" quiet="true" />
<property name="targets.clean-tmp.done" value="true" />
</target>
<target name="site-setup" depends="init" unless="targets.site-setup.done" description="Checkout the code and install the site">
<phingcall target="clean" />
<phingcall target="site-checkout" />
<phingcall target="site-install" />
<property name="targets.site-setup.done" value="true" />
</target>
<target name="site-update" depends="init" unless="targets.site-update.done" description="Update the web site">
<gitpull repository="${project.www}" gitPath="${system.git}" />
<drush command="updatedb" assume="yes" />
<drush command="pm-enable" assume="yes">
<param>${drupal.profile}</param>
</drush>
<phingcall target="drush-fr-all" />
<property name="targets.site-update.done" value="true" />
</target>
<target name="site-install" depends="init" unless="targets.site-install.done" description="Install the web site">
<drush command="site-install" assume="yes" haltonerror="${drupal.site-install.haltonerror}">
<option name="db-url" value="${drupal.db.url}" />
<option name="locale" value="${drupal.locale}" />
<option name="site-name" value="${drupal.sitename}" />
<option name="account-pass" value="${drupal.account.pass}" />
<option name="strict" value="'0'" />
<param>${drupal.profile}</param>
</drush>
<drush command="pm-enable" assume="yes">
<param>features</param>
</drush>
<phingcall target="env-setup" />
<!-- Fix permissions for the default site directory and settings. The owner must be able to delete the directories during subsequent
builds. -->
<chmod mode="0777">
<fileset dir="${project.www}/sites/default" defaultexcludes="false">
<include name="files/**" />
<include name="files" />
<exclude name="files/.htaccess" />
</fileset>
</chmod>
<chmod mode="0775">
<fileset dir="${project.www}/sites" defaultexcludes="false">
<include name="default/default.settings.php" />
<include name="default/settings.php" />
<include name="default" />
</fileset>
</chmod>
<phingcall target="drush-fr-all" />
<property name="targets.site-install.done" value="true" />
</target>
<target name="site-checkout" depends="init" unless="targets.site-checkout.done" description="Checkout the site">
<phingcall target="clean" />
<gitclone repository="${drupal.repo_url}" targetPath="${project.www}" />
<gitcheckout repository="${project.www}" branchname="${drupal.repo_branch}" gitPath="${system.git}" />
<property name="targets.site-checkout.done" value="true" />
</target>
<target name="env-setup" depends="init" unless="project.env-setup" description="Enable environment specific settings">
<if>
<and>
<isset property="env.modules" />
<not>
<equals arg1="${env.modules}" arg2="" />
</not>
</and>
<then>
<drush command="pm-enable" assume="yes">
<param>${env.modules}</param>
</drush>
</then>
</if>
<property name="project.env-setup" value="true" />
</target>
<target name="drush-fr-all" depends="init" description="Revert all features">
<drush command="features-revert-all" assume="yes">
<param>${drupal.feature_exclude}</param>
</drush>
</target>
<target name="drushrc-create" depends="init" description="Create a custom drushrc file for the site">
<copy file="${project.basedir}/settings/drushrc.php" todir="${project.www}/sites/default" overwrite="true" />
</target>
<target name="project-upgrade-core" depends="init" description="Upgrade drupal core">
<property name="project.upgrade.drupal.dir" value="${project.tmp}/upgrade/${project.timestamp}/drupal_tmp" />
<drush command="status" returnProperty="project.upgrade.drupal.version">
<option name="fields" value="drupal-version" />
</drush>
<property name="project.upgrade.drupal.version" value="${project.upgrade.drupal.version}" override="true">
<filterchain>
<replaceregexp>
<regexp pattern="[^\d.]+" replace="" />
</replaceregexp>
</filterchain>
</property>
<echo message="Cloning... This could take a couple of minutes. Drupal repo is huge!" />
<gitclone repository="git://drupalcode.org/project/drupal.git" targetPath="${project.upgrade.drupal.dir}" />
<exec level="info" dir="${project.upgrade.drupal.dir}" checkreturn="true" passthru="true"
command="${system.git} checkout ${project.upgrade.drupal.version}" />
<copy todir="${project.upgrade.drupal.dir}" overwrite="true">
<fileset dir="${project.www}">
<include name="**" />
<exclude name="LICENSE.txt" />
<exclude name="**/*.info" />
<exclude name="profiles/${drupal.profile}/**" />
<exclude name="sites/all/**" />
<exclude name="sites/default/**" />
</fileset>
</copy>
<exec level="info" dir="${project.upgrade.drupal.dir}" checkreturn="true" passthru="true" command="${system.git} diff > drupal.patch " />
<loadfile property="project.upgrade.drupal.patch" file="${project.upgrade.drupal.dir}/drupal.patch" />
<drush command="pm-releases" returnProperty="project.upgrade.drupal.releases">
<option name="fields" value="version" />
<option name="format" value="csv" />
<param>drupal</param>
</drush>
<input propertyname="project.upgrade.drupal.new_release" validargs="${project.upgrade.drupal.releases}" message="Which version do you want to upgarde to" />
<drush command="pm-download" assume="yes">
<option name="drupal-project-rename" value="drupal_new" />
<option name="destination" value="${project.upgrade.drupal.dir}" />
<param>drupal-${project.upgrade.drupal.new_release}</param>
</drush>
<delete includeemptydirs="true" failonerror="true">
<fileset dir="${project.www}" defaultexcludes="false">
<include name="**" />
<exclude name="profiles/${drupal.profile}/**" />
<exclude name="sites/all/**" />
<exclude name="sites/default/**" />
<exclude name=".git/**" />
<exclude name=".gitignore" />
</fileset>
</delete>
<copy todir="${project.www}" overwrite="true">
<fileset dir="${project.upgrade.drupal.dir}/drupal_new" defaultexcludes="false">
<include name="**" />
</fileset>
</copy>
<if>
<istrue value="${project.upgrade.drupal.patch}" />
<then>
<patch strip="1" haltonfailure="true" patchfile="${project.upgrade.drupal.dir}/drupal.patch" dir="${project.www}" />
</then>
</if>
</target>
<target name="project-upgrade-module" depends="init" description="Upgrade drupal module">
<propertyprompt propertyName="project.upgrade.module.name" promptText="Which module do you want to upgrade"
defaultValue="devel" />
<drush command="pm-info" returnProperty="project.upgrade.module.version">
<option name="fields" value="version" />
<option name="format" value="list" />
<param>${project.upgrade.module.name}</param>
</drush>
<if>
<istrue value="${project.upgrade.module.version}" />
<then>
<php expression="reset(explode('+', str_replace('-dev', '', '${project.upgrade.module.version}')));" returnProperty="project.upgrade.module.tag" />
<php expression="end(explode('+', str_replace('-dev', '', '${project.upgrade.module.version}')));" returnProperty="project.upgrade.module.commits" />
<if>
<equals arg1="${project.upgrade.module.tag}" arg2="${project.upgrade.module.commits}" />
<then>
<property name="project.upgrade.module.commits" value="0" override="true" />
</then>
</if>
<property name="project.upgrade.module.dir" value="${project.tmp}/upgrade/${project.timestamp}/${project.upgrade.module.name}" />
<echo>Cloning...</echo>
<gitclone repository="git://drupalcode.org/project/${project.upgrade.module.name}.git" targetPath="${project.upgrade.module.dir}" />
<exec level="info" dir="${project.upgrade.module.dir}" checkreturn="true" passthru="true"
command="${system.git} checkout `git rev-list HEAD ^${project.upgrade.module.tag} | tail -${project.upgrade.module.commits} | head -1`" />
<copy todir="${project.upgrade.module.dir}" overwrite="true">
<fileset dir="${project.www}/sites/all/modules/contrib/${project.upgrade.module.name}">
<include name="**" />
<exclude name="LICENSE.txt" />
<exclude name="**/*.info" />
</fileset>
</copy>
<exec level="info" dir="${project.upgrade.module.dir}" checkreturn="true" passthru="true"
command="${system.git} diff > ${project.upgrade.module.name}.patch " />
<loadfile property="project.upgrade.module.patch" file="${project.upgrade.module.dir}/${project.upgrade.module.name}.patch" />
<drush command="pm-releases" returnProperty="project.upgrade.module.releases">
<option name="fields" value="version" />
<option name="format" value="csv" />
<param>${project.upgrade.module.name}</param>
</drush>
<input propertyname="project.upgrade.module.new_release" validargs="${project.upgrade.module.releases}" message="Which version do you want to upgarde to" />
<delete dir="${project.www}/sites/all/modules/contrib/${project.upgrade.module.name}" includeemptydirs="true"
failonerror="true" />
<drush command="pm-download">
<param>${project.upgrade.module.name}-${project.upgrade.module.new_release}
</param>
</drush>
<if>
<istrue value="${project.upgrade.module.patch}" />
<then>
<patch strip="1" haltonfailure="true" patchfile="${project.upgrade.module.dir}/${project.upgrade.module.name}.patch"
dir="${project.www}/sites/all/modules/contrib/${project.upgrade.module.name}" />
</then>
</if>
</then>
<else>
<echo level="error">There is no such module found</echo>
</else>
</if>
</target>
</project>