-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
417 lines (357 loc) · 18.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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<?xml version="1.0" encoding="UTF-8"?>
<!--
## @file
## ADS Phing build script
## @version
## $Id: 596381b6a5a4773293efe09d800ea9a5a83f8efb $
##
## Read more:
## http://www.phing.info/
##
## Quick PEAR installation:
## $> pear channel-discover pear.phing.info
## $> pear install phing/phing
-->
<project name="build-ads" basedir="." default="build-ads">
<import file="${phing.dir.build_ads}/phing/includes/build.debug.xml" />
<!--
## Build
-->
<target name="build-ads" depends="
ads-make
"/>
<target name="ads-make" depends="
build-init,
build-drupal,
set-dir-permissions
"/>
<target name="ads-install" depends="
build-init,
install-drupal,
post-install-drupal
"/>
<target name="ads-install-skip-post-install-drupal" depends="
build-init,
install-drupal
"/>
<!--
## Initialise
-->
<import file="${phing.dir.build_ads}/phing/includes/build.import.xml" />
<target name="build-init" depends="build-load-properties"/>
<!--
## Load Properties
-->
<target name="build-load-properties">
<log message="Assigning project directories and files to phing properties...${line.separator}" level="debug"/>
<property name="project.dir.dist" value="${phing.dir.build_ads}"/>
<property name="project.dir.profile" value="${project.dir.dist}"/>
<property name="project.dir.src" value="${project.dir.profile}/src"/>
<!-- <property name="project.dir.taxonomies" value="${project.dir.src}/sites/all/modules/ads/ads_features"/> -->
<log message="Building ADS into "${project.dir.src}"" level="verbose"/>
<!-- <property name="project.dir.src.ads_features" value="${project.dir.src}/sites/all/modules/ads/ads_features"/> -->
<property name="project.file.makefile" value="build-ads.make"/>
<log message="Assigning drush properties...${line.separator}" level="debug"/>
<property name="project.drush.args" value="--verbose --yes"/>
<property name="project.drush.cmd" value="${phing.dir.build_ads}/vendor/drush/drush/drush ${project.drush.args}"/>
<property name="project.drush.make.args" value="-y --prepare-install --working-copy --no-gitinfofile --verbose --concurrency=4"/>
<property name="project.drush.make.args2" value="-y --no-core --prepare-install --working-copy --no-gitinfofile --verbose --concurrency=4"/>
<log message="Loading configuration file..." level="debug"/>
<available file="${project.dir.dist}/build.properties" property="project.properties.exist" />
<if>
<not><isset property="project.properties.exist"/></not>
<then>
<copy
file="${project.dir.dist}/phing/build.properties.example"
tofile="${project.dir.dist}/build.properties"
overwrite="true"/>
<!-- or: <exec command="cp -v ${project.dir.dist}/build.properties.example ${project.dir.dist}/build.properties"
dir="${project.dir.dist}" checkreturn="true" /> -->
<log message="" level="warning" />
<log message="Hello :)" level="warning" />
<log message="Thank you for installing ADS distribution." level="warning" />
<log message="I have created a build.properties in ${project.dir.dist}.${line.separator}" level="warning" />
<log message="ACTION REQUIRED" level="warning" />
<log message="Please edit this file with your settings." level="warning" />
<log message="And then re-run the script again." level="warning" />
<log message="Thank You :)" level="warning" />
<fail message="See you again in a moment...${line.separator}" />
<log message="" level="warning" />
</then>
<else>
<property file="${project.dir.dist}/build.properties" />
<if>
<isset property="properties.notset"/>
<then>
<log message="" level="error" />
<log message="ACTION REQUIRED!" level="error" />
<log message="Please edit ${project.dir.dist}/build.properties" level="error" />
<log message="After you finish, please delete properties.notset section." level="error" />
<log message="" level="error" />
<fail />
</then>
</if>
</else>
</if>
<!-- Enable the pulling from other forks -->
<if>
<isset property="pullfrom" />
<then>
<!-- <log message"Overriding gihub.user with ${pullfrom}" />
<property name="github.user" value="${pullfrom}"/>-->
</then>
</if>
<property environment="env" />
<!-- Checking for variable overrides by environment variables -->
<if>
<isset property="env.ADS_SEARCH"/>
<then>
<log message="Found environment variable ADS_SEARCH, overriding project.drupal.configure.search = "${env.ADS_SEARCH}"" level="verbose" indent="1" />
<property name="project.drupal.configure.search" value="${env.ADS_SEARCH}" override="true"/>
</then>
</if>
<log message="" level="verbose"/>
</target>
<!--
## Build Drupal code using drush make
-->
<target name="build-drupal" depends="build-init">
<log message="Downloading and building Drupal sources... (it may take a while)" level="verbose" />
<!-- Detection of makefile variant -->
<if>
<equals arg1="${project.drupal.build.stable}" arg2="true"/>
<then>
<property name="project.drupal.build.option.stable" value="stable" override="true"/>
</then>
<else>
<property name="project.drupal.build.option.stable" value="latest" override="true"/>
</else>
</if>
<property name="project.drupal.build.option.type" value="${project.drupal.build.type}" override="true"/>
<property name="project.file.makefile" value="build-ads-${project.drupal.build.option.stable}-${project.drupal.build.option.type}.make" override="true"/>
<exec command="${project.drush.cmd} make ${project.dir.profile}/${project.file.makefile} ${project.dir.src} ${project.drush.make.args}" dir="${project.dir.dist}" outputProperty="project.drupal.exists" passthru="1" LogOutput="true" />
<!--
<if><not><equals arg1="${project.drupal.exists}" arg2="0" /></not>
<then>
<log message="Drupal instance exists, updating the existing sources...${line.separator}" />
<exec command="${project.drush.cmd} make ${project.dir.profile}/${project.file.makefile} ${project.dir.src} ${project.drush.make.args2}" dir="${project.dir.dist}" LogOutput="true" />
</then>
</if>
-->
<available file="${project.dir.src}" property="project.src.exist" />
<if>
<not><isset property="project.src.exist"/></not>
<then>
<log message="" level="error" />
<log message="Drupal build failed, directory "${project.dir.src}" does not exist" level="error" />
<log message="" level="error" />
<fail message="Drupal build failed, directory "${project.dir.src}" does not exist" />
</then>
</if>
<if>
<isset property="out"/>
<then>
<log message="Moving Drupal build folder "${project.dir.src}" to destination "${out}"" level="debug" />
<move todir="${out}">
<fileset dir="${project.dir.src}">
<include name="**/*" />
</fileset>
</move>
</then>
</if>
<!-- Done -->
<log message="" level="info" />
<log message="Done" level="info" />
<log message="" level="info" />
<log message="NOTE:" level="info" />
<log message="Distribution can be found in the directory: ${project.dir.src}" level="info" />
<log message="You can move your newly created distribution to your webroot." level="info" />
<log message="Or you can install it by the following command:" level="info" />
<log message=" phing ads-install" level="info" />
<log message="" level="info" />
</target>
<target name="check-db" depends="build-init">
<log message="Checking database connection..." level="verbose" />
<property name="project.db.url" value="${project.db.driver}://${project.db.username}:${project.db.password}@${project.db.host}:${project.db.port}/${project.db.database}" />
<exec command="${project.drush.cmd} sql-query --db-url=${project.db.url} "SHOW TABLES;"" returnProperty="cmd.return" passthru="1" LogOutput="true" />
<if><not><equals arg1="${cmd.return}" arg2="0" /></not>
<then>
<log msg="Cannot access selected database! Check your database connection at "${project.db.url}"!" indent="1" />
<fail msg="Cannot access selected database! Check your database connection at "${project.db.url}"!" />
</then>
<else>
<log msg="OK" indent="1" />
</else>
</if>
<log msg="" />
</target>
<!--
## Install Drupal code using drush make
-->
<target name="install-drupal" depends="build-init, check-db">
<log message="Installing Drupal from the profile" level="verbose" />
<log message="" level="verbose" />
<property name="project.db.url" value="${project.db.driver}://${project.db.username}:${project.db.password}@${project.db.host}:${project.db.port}/${project.db.database}" />
<exec command="${project.drush.cmd} site-install ads --db-url=${project.db.url} --account-name=${project.drupal.admin.user} --account-mail="${project.drupal.admin.email}" --account-pass="${project.drupal.admin.pass}" --site-mail="${project.drupal.site.email}" --site-name="${project.drupal.site.name}" install_configure_form.site_default_country="${project.drupal.site.default_country}" install_configure_form.date_default_timezone="${project.drupal.site.default_time_zone}" update_notifications.update_status_module="${project.drupal.site.check_for_updates}" variables.file_private_path="${project.drupal.private.dir}""
dir="${project.dir.src}" returnProperty="cmd.return" passthru="1" LogOutput="true" />
<if><not><equals arg1="${cmd.return}" arg2="0" /></not>
<then>
<log msg="Can't install Drupal! Check your database connection at "${project.db.url}"!" indent="1" />
<fail msg="Can't install Drupal! Check your database connection at "${project.db.url}"!" />
</then>
</if>
<log msg="Drupal installed" />
<log msg="" />
</target>
<!--
## Set proper system permissions
-->
<target name="set-dir-permissions" depends="build-init">
<log message="Creating Drupal default files directory..." level="verbose" />
<mkdir dir="${project.dir.src}/${project.drupal.public.dir}" />
<log message="Creating Drupal private files directory..." level="verbose" />
<mkdir dir="${project.dir.src}/${project.drupal.private.dir}" />
<!-- Fix permissions for the default site directory and settings.
The owner must be able to delete the directories during subsequent builds. -->
<log message="Setting up the permissions..." level="verbose" />
<chmod file="${project.dir.src}/${project.drupal.private.dir}"
mode="0775" failonerror="true" />
<chmod file="${project.dir.src}/${project.drupal.public.dir}"
mode="0775" failonerror="true" />
</target>
<!--
## Run phing scripts
-->
<target name="run-phing-scripts" depends="build-init">
<!-- Build site -->
<if><equals arg1="${project.drupal.build.site}" arg2="true" />
<then>
<log message="Found project.drupal.build.site = true, executing build-site.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/build-site.xml" absolute="true" />
<execute-import-file-target name="build-site" />
</then>
</if>
<!-- Enable DB search -->
<if><equals arg1="${project.drupal.configure.search}" arg2="db" />
<then>
<log message="Found project.drupal.configure.search = db, executing enable-search-db.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/enable-search-db.xml" absolute="true" />
<execute-import-file-target name="enable-search-db" />
</then>
</if>
<!-- Enable Solr search -->
<if><equals arg1="${project.drupal.configure.search}" arg2="solr" />
<then>
<log message="Found project.drupal.configure.search = solr, executing enable-search-solr.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/enable-search-solr.xml" absolute="true" />
<execute-import-file-target name="enable-search-solr" />
</then>
</if>
<!-- Enable development environment -->
<if><equals arg1="${project.drupal.build.type}" arg2="dev" />
<then>
<log message="Found project.drupal.build.type = dev, executing build-dev-env.xml" level="verbose"/>
<import-file path="${phing.dir.build_ads}/phing/build-dev-env.xml" absolute="true" />
<execute-import-file-target name="build-dev-env" />
</then>
</if>
<!-- Drupal modules auto-configuration -->
<import-file path="${phing.dir.build_ads}/phing/build-configure.xml" absolute="true" />
<!-- We don't want locations import in this build -->
<property name="exclude" value="ads_locations" />
<!-- Configuring modules -->
<execute-import-file-target name="run-ads-configure" />
<!-- Generate taxonomy terms -->
<if><equals arg1="${project.drupal.generate.terms}" arg2="true" />
<then>
<log message="Found project.drupal.generate.terms = true, executing generate-terms.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-terms.xml" absolute="true" />
<execute-import-file-target name="generate-terms" />
</then>
</if>
<!-- Generate users -->
<if><equals arg1="${project.drupal.generate.users}" arg2="true" />
<then>
<log message="Found project.drupal.generate.users = true, executing generate-users.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-users.xml" absolute="true" />
<execute-import-file-target name="generate-users" />
</then>
</if>
<!-- Generate content -->
<if><equals arg1="${project.drupal.generate.content}" arg2="true" />
<then>
<log message="Found project.drupal.generate.content = true, executing generate-content.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-content.xml" absolute="true" />
<execute-import-file-target name="generate-content" />
</then>
</if>
<!-- Generate adverts -->
<if><equals arg1="${project.drupal.generate.ads}" arg2="true" />
<then>
<log message="Found project.drupal.generate.ads = true, executing generate-ads.xml" level="verbose" />
<import-file path="${phing.dir.build_ads}/phing/generate-ads.xml" absolute="true" />
<execute-import-file-target name="generate-ads" />
</then>
</if>
</target>
<target name="configure" depends="build-init">
<import-file path="${phing.dir.build_ads}/phing/build-configure.xml" absolute="true" />
<execute-import-file-target name="run-ads-configure" />
</target>
<!--
## Finalize Drupal installation
-->
<target name="post-install-drupal" depends="build-init">
<!-- Somehow ads_content_types is not enabling votingapi and fivestar modules even if fivestar in its dependency, we have to enable them explicitly -->
<!--
<log message="Enabling votingapi and fivestar modulse (should be enabled along with ads_content_types, assuming it's a features module bug)" level="verbose" />
<exec command="${project.drush.cmd} en votingapi fivestar" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
-->
<!-- Update Database and Features -->
<log message="Updating database" level="verbose" />
<exec command="${project.drush.cmd} updb" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
<!-- Clear cache -->
<!--
<log message="Clearing Drupal cache...${line.separator}" />
<exec command="${project.drush.cmd} cc all" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
-->
<!-- Revert configuration from features -->
<!-- Check if grep command is available -->
<exec command="grep --version" dir="${project.dir.src}" outputProperty="project.cmd.avail.grep" />
<if>
<contains string="${project.cmd.avail.grep}" substring="grep" />
<then>
<!-- Checking if "features" module is enabled -->
<exec command="${project.drush.cmd} pm-info features | grep -ci --regexp="Status\s+:\s:(enabled)"" dir="${project.dir.src}" outputProperty="project.enabledmodules.features" />
<if>
<equals arg1="${project.enabledmodules.features}" arg2="1" />
<then>
<!-- Pull new configuration from features -->
<log message="Features module is enabled, reverting features" level="verbose" />
<exec command="${project.drush.cmd} features-revert-all" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
</then>
<else>
<log message="Features are not enabled. No revert will take place" level="verbose" />
</else>
</if>
</then>
</if>
<!-- Run cron -->
<log message="Running Drupal cron" level="verbose" />
<exec command="${project.drush.cmd} --php="`which php` -d sendmail_path=/dev/null" core-cron" dir="${project.dir.src}" checkreturn="true" LogOutput="true" spawn="true" />
<!-- Run additional phing scripts -->
<log message="Checking phing scripts" level="verbose" />
<execute-import-file-target name="run-phing-scripts" />
<!-- Done -->
<log message="" level="info" />
<log message="Done" level="info" />
<log message="" level="info" />
<log message="NOTE:" level="info" />
<log message="You can move your newly installed distribution to your webroot" level="info" />
<log message="Or you should point your webroot at the '${project.dir.src}' folder" level="info" />
<log message="Also make sure that the following folders:" level="info" />
<log message="${project.drupal.public.dir}, ${project.drupal.private.dir}" level="info" />
<log message="are write accessible by your web server user." level="info" />
<log message="" level="info" />
</target>
</project>