-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.xml
385 lines (320 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
<project name="federated-search-demo" default="list">
<!-- Run with: vendor/bin/phing -->
<!-- For a list of commands, try: vendor/bin/phing -Dbuild.env=vagrant -l -->
<!-- Provide the <drush /> task. -->
<taskdef name="drush" classname="Drush\Task" />
<!-- Target: install-all -->
<target name="install-all" description="Install all three Drupal sites in the Federated Search Demo">
<phingcall target="install-d7" />
<phingcall target="install-d7-domain" />
<phingcall target="install-d8" />
<phingcall target="install-d8-domain" />
<phingcall target="react" />
<property name="index.domains" value="y" />
<phingcall target="solr-reindex" />
</target>
<!-- Target: install-no-domain -->
<target name="install-no-domain" description="Install all three Drupal sites in the Federated Search Demo">
<phingcall target="install-d7" />
<phingcall target="install-d8" />
<phingcall target="react" />
<property name="index.domains" value="n" />
<phingcall target="solr-reindex" />
</target>
<!-- Target: install-d8 -->
<target name="install-d8" description="Install one of the Drupal 8 sites; specify which site with -Ddrush.root=web/d8/docroot">
<phingcall target="init" />
<property name="drush.root" value="web/d8/docroot" />
<property name="site.name" value="Federated Search Drupal 8" />
<exec command="composer install" dir="${drush.root}/.." passthru="true" />
<phingcall target="install-drupal-by-path" />
<!-- Create demo content -->
<drush command="pm-enable" assume="yes">
<param>federated_default_content</param>
</drush>
<!-- Copy demo files -->
<copy todir="${drush.root}/sites/default/files" mode="777">
<fileset dir="${drush.root}/modules/custom/federated_default_content/assets">
<include name="**/*.jpg" />
</fileset>
</copy>
<!-- Uninstall the demo content modules -->
<drush command="pm-uninstall" assume="yes">
<param>federated_default_content</param>
</drush>
<drush command="search-api:clear" assume="yes">
<param>federated_search</param>
</drush>
<exec command="drush @d8 search-api:index federated_search -y" />
</target>
<!-- Target: install-d8-domain -->
<target name="install-d8-domain" description="Install domain-enabled Drupal 8 sites; specify which site with -Ddrush.root=web/d8/docroot">
<phingcall target="init" />
<property name="drush.root" value="web/d8-domain/docroot" />
<property name="site.name" value="Federated Search Domain 8" />
<exec command="composer install" dir="${drush.root}/.." passthru="true" />
<phingcall target="install-drupal-by-path" />
<!-- Create demo content -->
<drush command="pm-enable" assume="yes">
<param>federated_default_content</param>
</drush>
<!-- Copy demo files -->
<copy todir="${drush.root}/sites/default/files" mode="777">
<fileset dir="${drush.root}/modules/custom/federated_default_content/assets">
<include name="**/*.jpg" />
</fileset>
</copy>
<!-- Uninstall the demo content modules -->
<drush command="pm-uninstall" assume="yes">
<param>federated_default_content</param>
</drush>
<drush command="search-api:clear" assume="yes">
<param>federated_search</param>
</drush>
<exec command="drush @d8-domain.one search-api:index federated_search -y" />
<!-- Rebuild node acces permissions. No direct drush command for this
as per https://www.drupal.org/project/devel/issues/2677218#comment-10907984 -->
<drush command="php-eval">
<param>'node_access_rebuild();'</param>
</drush>
</target>
<!-- Target: install-drupal-by-path -->
<target name="install-drupal-by-path" hidden="true">
<drush command="status" returnProperty="drupal.site_padded"><option name="field" value="site" /></drush>
<php function="trim" returnProperty="drupal.site"><param value="${drupal.site_padded}" /></php>
<property name="drupal.files" value="${drupal.site}/files" />
<property name="drupal.private" value="${drupal.site}/private" />
<!-- Swap out the composer file for our git repository -->
<delete dir="${drush.root}/modules/contrib/search_api_federated_solr" />
<symlink link="${drush.root}/modules/contrib/search_api_federated_solr" target="../../../../../src/search_api_federated_solr" />
<delete dir="${drush.root}/modules/contrib/search_api_field_map" />
<symlink link="${drush.root}/modules/contrib/search_api_field_map" target="../../../../../src/search_api_field_map" />
<!-- The sites subdirectory and settings.php should be writable; Drupal will
change the permissions on this directory after install. -->
<chmod file="${drush.root}/${drupal.site}" mode="777" />
<!-- Delete and re-create the public files directory -->
<delete dir="${drush.root}/${drupal.files}" />
<mkdir dir="${drush.root}/${drupal.files}" mode="777" />
<!-- Delete and re-create the private files directory -->
<if>
<and>
<isset property="drupal.private"/>
<not>
<equals arg1="${drupal.private}" arg2="" trim="true" />
</not>
</and>
<then>
<delete dir="${drush.root}/${drupal.private}" />
<mkdir dir="${drush.root}/${drupal.private}" mode="777" />
</then>
</if>
<!-- Install the site. -->
<drush command="site-install" assume="yes">
<option name="account-name">admin</option>
<option name="account-pass">admin</option>
<option name="site-name">${site.name}</option>
<!-- We should be able to use the existing-config flag, but cannot.
See https://www.drupal.org/project/drupal/issues/2982052 -->
<param>config_installer</param>
</drush>
<!-- The public files directory, and everything in it, needs to be world writable. -->
<exec command="chmod -R 777 ${drush.root}/${drupal.files}" checkreturn="true" />
</target>
<!-- Target: install-d7 -->
<target name="install-d7" description="Install the D7 site">
<phingcall target="init" />
<!-- Drush 9/10 are not compatible with Drupal 7, so we can't use a regular drush
alias. Hence, we provide drush.root and drush.uri, which the <drush> task
uses in its commands. -->
<property name="drush.root" value="web/d7/docroot" />
<property name="drush.uri" value="http://d7.fs-demo.local" />
<exec command="composer install" dir="${drush.root}/.." passthru="true" />
<!-- Swap out the composer file for our git repository -->
<delete dir="${drush.root}/sites/all/modules/contrib/search_api_federated_solr" />
<symlink link="${drush.root}/sites/all/modules/contrib/search_api_federated_solr" target="../../../../../../../src/search_api_federated_solr-7.x" />
<drush command="site-install" assume="yes">
<option name="site-name">Search Drupal 7</option>
<option name="account-pass">admin</option>
<param>standard</param>
</drush>
<!-- The public files directory, and everything in it, needs to be world writable. -->
<exec command="chmod -R 777 ${drush.root}/sites/default/files" checkreturn="true" />
<!-- Install default configuration and content. -->
<drush command="pm-enable" assume="yes">
<param>features_search_api_config</param>
<param>federated_default_content</param>
</drush>
<!-- The public files directory, and everything in it, needs to be world writable,
but the content creation step changes that, so we do it again. -->
<exec command="chmod -R 777 ${drush.root}/sites/default/files" checkreturn="true" />
<!-- The feature is not loading properly due to file permissions, but does reload correctly. -->
<drush command="features-revert" assume="yes">
<param>federated_default_content</param>
</drush>
<drush command="pm-disable" assume="yes">
<param>overlay</param>
<param>toolbar</param>
</drush>
<drush command="search-api-reindex" assume="yes" />
<drush command="search-api-index" assume="yes" />
</target>
<!-- Target: install-d7 -->
<target name="install-d7-domain" description="Install the D7 domain site">
<phingcall target="init" />
<!-- Drush 9/10 are not compatible with Drupal 7, so we can't use a regular drush
alias. Hence, we provide drush.root and drush.uri, which the <drush> task
uses in its commands. -->
<property name="drush.root" value="web/d7-domain/docroot" />
<property name="drush.uri" value="http://d7-1.fs-demo.local" />
<exec command="composer install" dir="${drush.root}/.." passthru="true" />
<!-- Swap out the composer file for our git repository -->
<delete dir="${drush.root}/sites/all/modules/contrib/search_api_federated_solr" />
<symlink link="${drush.root}/sites/all/modules/contrib/search_api_federated_solr" target="../../../../../../../src/search_api_federated_solr-7.x" />
<!-- Copy settings files. Domain Access must be added after install. -->
<chmod file="${drush.root}/sites/default/" mode="0775" />
<copy file="config/sites/d7-domain/settings-install.php" tofile="${drush.root}/sites/default/settings.php" overwrite="true" />
<drush command="site-install" assume="yes">
<option name="site-name">Domain 7</option>
<option name="account-pass">admin</option>
<param>standard</param>
</drush>
<!-- Copy settings files that enable Domain Access. -->
<chmod file="${drush.root}/sites/default/" mode="0775" />
<chmod file="${drush.root}/sites/default/settings.php" mode="0775" />
<copy file="config/sites/d7-domain/settings.php" tofile="${drush.root}/sites/default/settings.php" overwrite="true" />
<!-- The public files directory, and everything in it, needs to be world writable. -->
<exec command="chmod -R 777 ${drush.root}/sites/default/files" checkreturn="true" />
<!-- Install default configuration and content. -->
<drush command="pm-enable" assume="yes">
<param>features_search_api_config</param>
<param>federated_default_content</param>
</drush>
<!-- The public files directory, and everything in it, needs to be world writable,
but the content creation step changes that, so we do it again. -->
<exec command="chmod -R 777 ${drush.root}/sites/default/files" checkreturn="true" />
<!-- The feature is not loading properly due to file permissions, but does reload correctly. -->
<drush command="features-revert" assume="yes">
<param>federated_default_content</param>
</drush>
<drush command="pm-disable" assume="yes">
<param>overlay</param>
<param>toolbar</param>
</drush>
<drush command="search-api-reindex" assume="yes" />
<drush command="search-api-index" assume="yes" />
<!-- Rebuild node acces permissions. No direct drush command for this
as per https://www.drupal.org/project/devel/issues/2677218#comment-10907984 -->
<drush command="php-eval">
<param>'node_access_rebuild();'</param>
</drush>
</target>
<!-- Target: init -->
<target name="init" description="Initialize the repo for development">
<available file="src" type="dir" property="src.checkout" value="y" />
<if>
<equals arg1="${src.checkout}" arg2="y" />
<then>
<echo message="Git sources already checked out." />
</then>
<else>
<mkdir dir="src" mode="777" />
<exec command="git clone --branch=8.x-3.x https://github.com/palantirnet/search_api_federated_solr.git" dir="src" checkreturn="true" />
<exec command="git clone --branch=8.x-3.x https://github.com/palantirnet/search_api_field_map.git" dir="src" checkreturn="true" />
<exec command="git clone --branch=7.x-2.x https://github.com/palantirnet/search_api_federated_solr.git search_api_federated_solr-7.x" dir="src" checkreturn="true" />
</else>
</if>
</target>
<!-- Target: init-git -->
<target name="init-git" description="Initialize the repo for development with git. This action will delete existing checkouts.">
<available file="src" type="dir" property="src.checkout" value="y" />
<if>
<equals arg1="${src.checkout}" arg2="y" />
<then>
<delete dir="src" includeemptydirs="true" verbose="true" />
<mkdir dir="src" mode="777" />
</then>
</if>
<echo message="git clone --branch=8.x-3.x [email protected]:palantirnet/search_api_federated_solr.git" />
<exec command="git clone --branch=8.x-3.x [email protected]:palantirnet/search_api_federated_solr.git" dir="src" checkreturn="true" />
<exec command="git remote add drupal [email protected]:project/search_api_federated_solr.git" dir="src/search_api_federated_solr" checkreturn="true" />
<echo message="git clone --branch=8.x-3.x [email protected]:palantirnet/search_api_field_map.git" />
<exec command="git clone --branch=8.x-3.x [email protected]:palantirnet/search_api_field_map.git" dir="src" checkreturn="true" />
<exec command="git remote add drupal [email protected]:project/search_api_field_map.git" dir="src/search_api_field_map" checkreturn="true" />
<echo message="git clone --branch=7.x-2.x [email protected]:palantirnet/search_api_federated_solr.git search_api_federated_solr-7.x" />
<exec command="git clone --branch=7.x-2.x [email protected]:palantirnet/search_api_federated_solr.git search_api_federated_solr-7.x" dir="src" checkreturn="true" />
<exec command="git remote add drupal [email protected]:project/search_api_federated_solr.git" dir="src/search_api_federated_solr-7.x" checkreturn="true" />
</target>
<!-- Target: solr-clear -->
<target name="solr-clear" description="Delete all entries in the local Solr 'drupal8' core">
<if>
<not>
<isset property="dump.confirm" />
</not>
<then>
<input message="Would you like to clear the SOLR index? This action cannot be undone." propertyName="dump.confirm" defaultValue="y" validArgs="y,n" />
</then>
</if>
<if>
<equals arg1="${dump.confirm}" arg2="y" />
<then>
<!-- Send an update command to the solr core telling it to delete everything.
The query needs to be escaped to pass through phing, but here it is unescaped:
http://federated-search-demo.local:8984/solr/drupal8/update?commit=true&stream.body=<delete><query>*:*</query></delete>
-->
<exec command="curl 'http://federated-search-demo.local:8983/solr/drupal8/update?commit=true&stream.body=<delete><query>*:*</query></delete>'" passthru="true" escape="false" checkreturn="true" />
<exec command="curl 'http://federated-search-demo.local:8983/solr/drupal7/update?commit=true&stream.body=<delete><query>*:*</query></delete>'" passthru="true" escape="false" checkreturn="true" />
<echo message="Your Solr is now clean."/>
</then>
</if>
</target>
<!-- Target: solr-reindex-all -->
<target name="solr-reindex-all" description="Delete and rebuild the SOLR index">
<property name="index.domains" value="y" />
<phingcall target="solr-reindex" />
</target>
<!-- Target: solr-reindex -->
<target name="solr-reindex" description="Delete and rebuild the SOLR index">
<property name="dump.confirm" value="y" />
<phingcall target="solr-clear" />
<!-- Index Drupal 7 -->
<exec command="drush --root='web/d7/docroot' --uri='http://d7.fs-demo.local' search-api-reindex federated_search -y" />
<exec command="drush --root='web/d7/docroot' --uri='http://d7.fs-demo.local' search-api-index federated_search -y" />
<echo message="Drupal 7 indexed." />
<!-- Index Drupal 8 -->
<exec command="drush @d8 search-api:reset-tracker federated_search -y" />
<exec command="drush @d8 search-api:index federated_search -y" />
<echo message="Drupal 8 indexed." />
<if>
<equals arg1="${index.domains}" arg2="y" />
<then>
<!-- Index Drupal 8 Domain -->
<exec command="drush @d8-domain.one search-api:reset-tracker federated_search -y" />
<exec command="drush @d8-domain.one search-api:index federated_search -y" />
<echo message="Drupal 8 domain indexed." />
<!-- Index Drupal 7 Domain -->
<exec command="drush --root='web/d7-domain/docroot' --uri='http://d7-1.fs-demo.local' search-api-reindex federated_search -y" />
<exec command="drush --root='web/d7-domain/docroot' --uri='http://d7-1.fs-demo.local' search-api-index federated_search -y" />
<echo message="Drupal 7 domain indexed." />
</then>
</if>
</target>
<!-- Target: React settings -->
<target name="react" description="Setup the React demo">
<copy file="config/sites/react/settings.example.js" tofile="web/react/app/settings.js" overwrite="true" />
<copy file="config/sites/react/custom.example.css" tofile="web/react/app/custom.css" overwrite="true" />
<echo message="React application setup on http://react.fs-demo.local" />
</target>
<!-- Target: start-selenium -->
<target name="start-selenium">
<exec command='java -jar -Dwebdriver.chrome.driver="/usr/local/share/chromedriver/chromedriver" /usr/local/share/selenium/selenium-server-standalone.jar >/dev/null 2>&1 &' dir="/home" />
</target>
<!-- Target: behat -->
<target name="behat">
<phingcall target="start-selenium" />
<exec command='vendor/bin/behat --tags=javascript' logoutput="true" checkreturn="true" />
</target>
<!-- Default target: list -->
<target name="list" hidden="true">
<exec command="phing -q -f ${phing.file} -l" passthru="true"/>
</target>
</project>