forked from acquia/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
225 lines (198 loc) · 9.57 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Lightning" default="env">
<!-- Locations of required binaries. -->
<property name="drush" value="${project.basedir}/bin/drush" />
<property name="composer" value="/usr/local/bin/composer" />
<property name="npm" value="/usr/local/bin/npm" />
<property name="rsync" value="/usr/bin/rsync" />
<property name="bzip2" value="/usr/bin/bzip2" />
<property name="bunzip2" value="/usr/bin/bunzip2" />
<!-- Database credentials. -->
<property name="db.type" value="mysql" />
<property name="db.host" value="localhost" />
<property name="db.user" value="root" />
<property name="db.password" value="" />
<property name="db.database" value="lightning" />
<property name="db.url" value="${db.type}://${db.user}:${db.password}@${db.host}/${db.database}" />
<!-- Installation and build-specific variables. -->
<property name="docroot" value="docroot" />
<property name="profile" value="${docroot}/profiles/lightning" />
<property name="site" value="${docroot}/sites/default" />
<property name="version" value="HEAD" />
<property name="fixture" value="${project.basedir}/tests/fixtures/${version}.sql" />
<!-- Finds required binaries. -->
<target name="env">
<if>
<not>
<available file="${drush}" property="drush.exists" />
</not>
<then>
<exec command="which drush" outputProperty="drush" />
</then>
</if>
<exec command="which composer" outputProperty="composer" />
<exec command="which npm" outputProperty="npm" />
<exec command="which rsync" outputProperty="rsync" />
<exec command="which bzip2" outputProperty="bzip2" />
<exec command="which bunzip2" outputProperty="bunzip2" />
<echo message="Found Drush: ${drush}" />
<echo message="Found Composer: ${composer}" />
<echo message="Found NPM: ${npm}" />
<echo message="Found rsync: ${rsync}" />
<echo message="Found bzip2: ${bzip2}" />
<echo message="Found bunzip2: ${bunzip2}" />
</target>
<!-- Syncs the Lightning profile into the Drupal code base. -->
<target name="push" depends="env">
<!-- Create the destination if it doesn't exist. -->
<mkdir dir="${profile}" />
<!--
bower.json may have changed, so reinstall front-end dependencies using
the version of Bower installed locally in node_modules. The
install-libraries script lives in package.json.
-->
<exec command="${npm} run install-libraries" passthru="true" />
<!-- rsync the profile, excluding developer flotsam. -->
<filesync destinationDir="${profile}" rsyncPath="${rsync}" sourceDir="." verbose="false" exclude=".idea,bin,build.xml,.git,.gitignore,${docroot},karma.conf.js,*.make,node_modules,.travis.yml,vendor" />
<!-- JS libraries and contrib modules were copied over by the file sync. -->
<delete dir="libraries" failonerror="true" quiet="true" />
<delete dir="modules/contrib" failonerror="true" quiet="true" />
</target>
<target name="pull" depends="env">
<filesync destinationDir="." rsyncPath="${rsync}" sourceDir="${profile}/" verbose="false" exclude="libraries,modules/contrib,behat.local.yml" />
</target>
<!-- Prepares the docroot for installation via the UI. -->
<target name="preinstall" depends="uninstall">
<if>
<not>
<isset property="www.user" />
</not>
<then>
<exec command="whoami" outputProperty="www.user" />
</then>
</if>
<copy file="${site}/default.settings.php" tofile="${site}/settings.php" />
<chmod file="${site}/settings.php" mode="0775" />
<mkdir dir="${site}/files" mode="0775" />
<if>
<and>
<isset property="www.user" />
<isset property="www.group" />
</and>
<then>
<chown file="${site}/settings.php" user="${www.user}" group="${www.group}" />
<chown file="${site}/files" user="${www.user}" group="${www.group}" />
</then>
</if>
</target>
<!-- Installs Lightning and sets it up for development. -->
<target name="install" depends="env">
<!-- Use passthru() when executing drush site-install so that we'll know if errors occur. -->
<exec command="${drush} site-install lightning --yes --account-pass=admin --db-url=${db.url}" dir="${docroot}" passthru="true" />
<exec command="${drush} config-set system.performance css.preprocess 0 --yes --format=boolean" dir="${docroot}" />
<exec command="${drush} config-set system.performance js.preprocess 0 --yes --format=boolean" dir="${docroot}" />
<exec command="${drush} config-set system.logging error_level all --yes" dir="${docroot}" />
<!-- Set up Media Entity Twitter to use Twitter's API for thumbnail generation. -->
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.use_twitter_api 1 --yes --format=boolean" dir="${docroot}" />
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.consumer_key EOPhWrgHCRnCB9cGualb1UVBM --yes" dir="${docroot}" />
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.consumer_secret AX5w9QYDvUJWdD0y0g2EtG3tFIZC9Lg4kR21iaAYakkPG8YKIp --yes" dir="${docroot}" />
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.oauth_access_token 52258222-ICStkPK2QcFN5d7v1FKJ1BMnqqPuuJnLIDr12Jsjs --yes" dir="${docroot}" />
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.oauth_access_token_secret Z4qff1DPLhqxHwei0jXgsnU0xdBFET4wSpQYn6Si3G3lF --yes" dir="${docroot}" />
<exec command="${drush} config-set media_entity.bundle.tweet type_configuration.generate_thumbnails 1 --yes --format=boolean" dir="${docroot}" />
<!--
Install Lightning Preview, which is not installed by default because it's experimental.
Enable passthru() for this as well since it has a lot of dependencies and is therefore
more prone to errors than other extensions.
-->
<exec command="${drush} pm-enable lightning_preview --yes" dir="${docroot}" passthru="true" />
<if>
<isset property="www.group" />
<then>
<chown file="${site}/files" user="${env.USER}" group="${www.group}" />
</then>
</if>
</target>
<!-- Prepares Lightning for the drupal.org packaging system. -->
<target name="package">
<!-- Create a symlink to the installed libraries so that the packaging script can scan 'em. -->
<symlink target="${profile}/libraries" link="libraries" />
<exec command="./package" />
<delete file="libraries" />
</target>
<!-- Builds a Lightning code base from legacy Drush make files. -->
<target name="build-legacy" depends="env">
<if>
<available file="${docroot}" property="docroot.exists" />
<then>
<phingcall target="package" />
<delete dir="${docroot}" />
</then>
</if>
<exec command="${drush} make drupal-org-core.make ${docroot} --yes" />
<exec command="${drush} make drupal-org.make ${docroot} --no-core --yes" />
<!-- Because legacy builds are not Composer-aware, we need to explicitly
require dependencies. Eugh. -->
<exec command="${composer} require drush/drush drupal/drupal-extension j7mbo/twitter-api-php" dir="${docroot}" />
<phingcall target="push" />
</target>
<!-- Destroys the Drupal installation, but leaves the code base intact. -->
<target name="uninstall">
<if>
<available file="${site}" property="site.exists" />
<then>
<chmod file="${site}" mode="0755" />
<delete failonerror="true" includeemptydirs="true">
<fileset dir="${site}">
<include name="settings.php" />
<include name="files/**" />
</fileset>
</delete>
</then>
</if>
<phingcall target="reset-db" />
</target>
<!-- Destroys the installed code base. -->
<target name="destroy">
<delete failonerror="true" includeemptydirs="true">
<fileset dir="." defaultexcludes="false">
<include name="bin/**" />
<include name="${docroot}/**" />
<include name="node_modules/**" />
<include name="vendor/**" />
</fileset>
</delete>
</target>
<!-- Generates a database snapshot from the current code base. -->
<target name="memorize" depends="env">
<phingcall target="reset-db" />
<phingcall target="install" />
<exec command="${drush} sql-dump" dir="${docroot}" output="${fixture}" />
<exec command="${bzip2} --force ${fixture}" />
</target>
<!-- Imports an existing database snapshot. -->
<target name="remember" depends="env">
<if>
<!-- Check if the fixture exists and exit gracefully if it doesn't. -->
<available property="fixture_exists" file="${fixture}.bz2" />
<then>
<!-- Import the fixture into a clean database to prevent table collisions. -->
<phingcall target="reset-db" />
<!-- Inflate and execute the fixture. -->
<exec command="${bunzip2} --keep ${fixture}.bz2" />
<pdosqlexec url="${db.type}:host=${db.host};dbname=${db.database}" userid="${db.user}" password="${db.password}" src="${fixture}" />
<!-- Delete the inflated fixture. -->
<delete file="${fixture}" />
</then>
<else>
<echo message="${version} fixture does not exist." />
</else>
</if>
</target>
<!-- Empties the database by dropping and recreating it. -->
<target name="reset-db">
<!-- pdosqlexec requires an SQL file to execute. -->
<echo message="DROP DATABASE ${db.database}; CREATE DATABASE ${db.database};" file=".reset.sql" />
<pdosqlexec url="${db.type}:host=${db.host}" userid="${db.user}" password="${db.password}" src=".reset.sql" />
<delete file=".reset.sql" />
</target>
</project>