-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.xml
245 lines (216 loc) · 10.9 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Demo Framework" default="env">
<taskdef name="setxmlproperty" classpath="${project.basedir}/src/Task" classname="SetXMLPropertyTask" />
<!-- Locations of required binaries. -->
<property name="drush" value="${project.basedir}/vendor/bin/drush" />
<property name="drupal" value="${project.basedir}/vendor/bin/drupal" />
<property name="composer" value="/usr/local/bin/composer" />
<property name="rsync" value="/usr/bin/rsync" />
<property name="bzip2" value="/usr/bin/bzip2" />
<property name="bunzip2" value="/usr/bin/bunzip2" />
<property name="tar" value="/usr/bin/tar" />
<property name="yaml-cli" value="${project.basedir}/vendor/bin/yaml-cli" />
<!-- 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="df" />
<property name="db.url" value="${db.type}://${db.user}:${db.password}@${db.host}/${db.database}" />
<!-- Installation and build-specific variables. -->
<property name="url" value="http://127.0.0.1" />
<property name="docroot" value="docroot" />
<property name="profile" value="${docroot}/profiles/df" />
<property name="site" value="${docroot}/sites/default" />
<property name="version" value="HEAD" />
<property name="fixture" value="${project.basedir}/tests/fixtures/${version}.sql" />
<property name="cloud.subscription" value="demoframeworktests" />
<property name="scenario" value="df" />
<!-- Attempts to find global Drush install and determine if it's 8.1.15 -->
<target name="find-drush8" depends="env">
<exec command="drush --version" outputProperty="global-drush-version" />
<if>
<contains substring="8.1.15" string="${global-drush-version}" />
<then>
<exec command="which drush" outputProperty="drush8" />
<echo message="Found Drush 8: ${drush8}" />
</then>
<else>
<fail message="No global Drush 8 installed." />
</else>
</if>
</target>
<!-- 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 rsync" outputProperty="rsync" />
<exec command="which bzip2" outputProperty="bzip2" />
<exec command="which bunzip2" outputProperty="bunzip2" />
<exec command="which tar" outputProperty="tar" />
<echo message="Found Drush: ${drush}" />
<echo message="Found Composer: ${composer}" />
<echo message="Found rsync: ${rsync}" />
<echo message="Found bzip2: ${bzip2}" />
<echo message="Found bunzip2: ${bunzip2}" />
<echo message="Found tar: ${tar}" />
</target>
<!-- Syncs the Demo Framework profile into the Drupal code base. -->
<target name="push" depends="env">
<!-- Create the destination if it doesn't exist. -->
<mkdir dir="${profile}" />
<!-- rsync the profile, excluding developer flotsam. -->
<filesync destinationDir="${profile}" rsyncPath="${rsync}" sourceDir="." verbose="false" exclude=".ddev,.idea,bin,build.xml,.git,.gitignore,${docroot},karma.conf.js,*.make,node_modules,.travis.yml,vendor" />
</target>
<target name="pull" depends="env">
<filesync destinationDir="." rsyncPath="${rsync}" sourceDir="${profile}/" verbose="false" exclude="modules/contrib" />
</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 Demo Framework 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="${drupal} site:install ${scenario} --db-type=${db.type} --db-host=${db.host} --db-name=${db.database} --db-user=${db.user} --db-pass=${db.password} --no-interaction --force" passthru="true" />
<chmod file="${site}" mode="0755" />
<!-- Prepare PHPUnit. -->
<mkdir dir="${docroot}/modules" />
<mkdir dir="${docroot}/themes" />
<mkdir dir="${docroot}/sites/simpletest" />
<if>
<not>
<available property="phpunit.xml" file="${docroot}/core/phpunit.xml" />
</not>
<then>
<copy file="${docroot}/core/phpunit.xml.dist" tofile="${docroot}/core/phpunit.xml" />
<setxmlproperty file="${docroot}/core/phpunit.xml" element="/phpunit/php/env[@name = 'SIMPLETEST_DB']" attribute="value" value="${db.url}" />
<setxmlproperty file="${docroot}/core/phpunit.xml" element="/phpunit/php/env[@name = 'SIMPLETEST_BASE_URL']" attribute="value" value="${url}" />
</then>
</if>
<!-- Generate Behat configuration. -->
<exec command="${drupal} behat:init ${url} --merge=${project.basedir}/docroot/profiles/df/tests/behat.yml" dir="${docroot}" />
<exec command="${drupal} behat:include ${project.basedir}/docroot/profiles/df/tests/features --with-subcontexts=${project.basedir}/docroot/profiles/df/tests/features/bootstrap --with-subcontexts=${project.basedir}/docroot/profiles/df/src/DFExtension/Context --with-subcontexts=${project.basedir}/docroot/profiles/lightning/src/LightningExtension/Context" dir="${docroot}" />
<!-- Export configuration for archaeological purposes. -->
<property name="config_fixture" value="${project.basedir}/tests/config/${scenario}" />
<exec command="${drupal} config:export --directory=${project.basedir}/tests/config/${scenario} --remove-uuid --remove-config-hash" dir="${docroot}" />
<!-- Change config values that might, or will, change on every install. -->
<exec command="${yaml-cli} unset:key ${config_fixture}/embed.button.media_browser.yml dependencies.content" />
<exec command="${yaml-cli} update:value ${config_fixture}/embed.button.media_browser.yml icon_uuid ''" />
<exec command="${yaml-cli} update:value ${config_fixture}/system.date.yml timezone.default UTC" />
<exec command="${yaml-cli} update:value ${config_fixture}/entity_browser.browser.image_browser.yml widgets ''" />
<exec command="${yaml-cli} update:value ${config_fixture}/entity_browser.browser.media_browser.yml widgets ''" />
<if>
<isset property="www.group" />
<then>
<chown file="${site}/files" user="${env.USER}" group="${www.group}" />
</then>
</if>
</target>
<!-- Enables a scenario. -->
<target name="scenario" depends="env">
<if>
<not>
<equals arg1="${scenario}" arg2="none" />
</not>
<then>
<exec command="${drush} enable-scenario ${scenario}" dir="${docroot}" />
</then>
</if>
</target>
<!-- Builds a Demo Framework code base from legacy Drush make files. -->
<target name="build-legacy" depends="find-drush8">
<exec command="${composer} nuke" />
<!-- Rebuild docroot and autoloader with makefiles. -->
<exec command="${drush8} make drupal-org-core.make ${docroot}" passthru="true" />
<exec command="${drush8} make drupal-org.make ${docroot} --no-core" passthru="true" />
<!-- Because legacy builds are not Composer-aware, we need to explicitly
require dependencies. -->
<exec command="${composer} require j7mbo/twitter-api-php league/oauth2-server:~6.0" dir="${docroot}" />
<!-- Place Demo Framework inside the docroot/profiles dir -->
<phingcall target="push" />
</target>
<!-- Generates a tarball of current docroot and saves it to the current user's
home directory. -->
<target name="tarball" depends="env">
<phingcall target="uninstall" />
<exec command="${tar} --exclude='.DS_Store' --exclude='._*' -zcf ~/df-${version}.tar.gz -s /^${docroot}/df-${version}/ ${docroot}" />
</target>
<!-- Creates a legacy-built tarball with composer dependencies suitable for
cloud. -->
<target name="cloud-tarball">
<phingcall target="build-legacy" />
<phingcall target="tarball" />
</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>
<!-- 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>
<!-- 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>
<!-- Replaces the existing settings file if it exists with the default and adds minimum necessary settings for cloud. -->
<target name="cloud-settings">
<delete file="${docroot}/sites/default/settings.php" />
<copy file="${docroot}/sites/default/default.settings.php" tofile="${docroot}/sites/default/settings.php" />
<append destFile="${docroot}/sites/default/settings.php" text="${line.separator}ini_set('memory_limit', '1024M');${line.separator}" />
<append destFile="${docroot}/sites/default/settings.php" text="${line.separator}require DRUPAL_ROOT . '/profiles/df/settings/df.settings.php';${line.separator}" />
<append destFile="${docroot}/sites/default/settings.php" text="$settings['install_profile'] = 'df';${line.separator}" />
<mkdir dir="config/default" />
<touch file="config/default/.gitkeep" />
</target>
<!-- Symlinks .git/hooks/pre-commit to our repo's pre-commit script -->
<target name="symlink">
<symlink link=".git/hooks/pre-commit" target="git-hooks/pre-commit" overwrite="true" />
</target>
</project>