-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
377 lines (334 loc) · 14.3 KB
/
build.xml
File metadata and controls
377 lines (334 loc) · 14.3 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="opm-server" default="build">
<!-- Fail if current user is root -->
<if>
<equals arg1="${env.USER}" arg2="root" />
<then>
<echo level="error" message="You are root!" />
<fail unless="enable.root" message="No builds as root!"/>
</then>
</if>
<!-- Fail if no.build property is set -->
<fail if="disable.build" message="Building forbidden on this system" />
<!-- Default environment this build file is executed for. This steers the property files to be included. -->
<property name="environment" value="dev" />
<!-- Absolute path to the project workspace root directory -->
<property name="path.base" value="${project.basedir}" />
<!-- include properties from user's home directory -->
<property file="${user.home}/build.properties" override="true" />
<!-- include general property file, containing default property definitions for all environments -->
<property file="${path.base}/build/properties/general.properties" override="true" />
<!-- include environment specific property file -->
<property file="${path.base}/build/properties/${environment}/default.properties" override="true" />
<!-- include general config file -->
<property file="${path.base}/build/config/default.ini" override="true" />
<!-- include environment specific config file -->
<property file="${path.base}/build/config/${environment}.ini" override="true" />
<!-- main targets -->
<!-- fixtures.default is now called by InstallBlueprintAssignments to ensure the affected databases always align -->
<echo level="info" message="Subtargets are not to be executed directly. Main targets are. You can create subtargets if you don't use
description argument in the target tag" />
<target
name="build"
depends="_info,
configure,
copyConfigFilesWithReplacingPlaceholders,
patchVendors,
configureApplication,
assetic-dump,
assets-install,
clear-permissions,
cache-clear"
description="Cleans the workspace, update sources and builds the whole application including unittests."
/>
<target
name="rebuild"
depends="_info,
configure,
copyConfigFilesWithReplacingPlaceholders,
configureApplication,
assetic-dump,
assets-install,
cache-clear"
description="Cleans the workspace, update sources and builds the whole application including unittests."
/>
<!-- End of main targets -->
<target name="patchVendors" description="Install patches to vendor sources not merged yet" hidden="true" unless="disable.vendors">
<echo message="Applying patches." />
<foreach param="filename" absparam="absfilename" target="_patchVendors">
<fileset dir="${path.base}/build/patches/">
<depth max="0" min="0" />
<include name="*.diff"/>
</fileset>
</foreach>
</target>
<!-- Not used for now -->
<target name="_patchVendors" description="Install patches to vendor sources not merged yet" hidden="true">
<echo message="Applying patch ${filename}" />
<if>
<available property="file" file="${absfilename}.orig" />
<then>
<echo message="Patch already applied" />
</then>
<else>
<patch patchfile="${absfilename}" strip="1" backups="false"
ignorewhitespace="true" haltonfailure="true" />
<touch file="${absfilename}.orig" />
</else>
</if>
</target>
<!-- Info -->
<target name="_info" hidden="true">
<echo level="warning" message="Building project opm-server in ${environment} environment." />
<echo message="" />
<if>
<isset property="enable.content.overwrite" />
<then>
<echo level="error" message="This build is not content save!" />
</then>
<else>
<echo level="warning" message="This build is contentent save" />
<echo message="Set the property 'enable.content.overwrite' to overwrite existing content." />
</else>
</if>
</target>
<!-- configure stuff -->
<target name="configure" hidden="true" description="Main target for all config relevant other targets.">
<delete dir="${path.base}/app/cache" quiet="true" includeemptydirs="true" />
<mkdir dir="${path.base}/app/cache" />
<mkdir dir="${config.path.logs}" />
<chmod file="${path.base}/app/cache" mode="0777" />
<chmod file="${config.path.logs}" mode="0777" />
<if>
<not>
<available file="${path.base}/bin" type="dir" />
</not>
<then>
<echo message="Creating bin dir on project root."/>
<mkdir dir="${path.base}/bin" />
</then>
</if>
<if>
<not>
<available file="${path.base}/web/css" type="dir" />
</not>
<then>
<echo message="Creating web/css"/>
<mkdir dir="${path.base}/web/css" />
</then>
</if>
<if>
<not>
<available file="${path.base}/web/js" type="dir" />
</not>
<then>
<echo message="Creating web/js"/>
<mkdir dir="${path.base}/web/js" />
</then>
</if>
</target>
<target name="installVendors" description="Installs the vendors directory based on composer.json" hidden="false"
unless="disable.vendors">
<echo message="Install vendors"/>
<if>
<not>
<available file="${path.base}/composer.lock" />
</not>
<then>
<exec command="${path.base}/composer.phar install --prefer-dist --verbose --optimize-autoloader"
checkreturn="true" passthru="true"/>
</then>
<else>
<warn message="vendors are ALLREADY installed. updateVendors is now executed" />
<phingcall target="updateVendors">
</phingcall>
</else>
</if>
<phingcall target="installNodeModules">
</phingcall>
</target>
<target name="updateVendors" description="Updates the vendors directory based on composer.json" hidden
="false" unless="disable.vendors">
<echo message="Update vendors"/>
<if>
<available file="${path.base}/composer.lock" />
<then>
<exec command="${path.base}/composer.phar update --prefer-dist --verbose" checkreturn="true"
passthru="true"/>
</then>
<else>
<warn message="vendors are NOT installed. Please use installVendors or composer.phar install" />
</else>
</if>
</target>
<target name="installNodeModules">
<if>
<not>
<available type="dir" file="${path.base}/node_modules" />
</not>
<then>
<echo message="Install node modules"/>
<exec command="npm install"
checkreturn="true" passthru="true"/>
</then>
<else>
<echo message="Update node modules"/>
<exec command="npm update"
checkreturn="true" passthru="true"/>
</else>
</if>
</target>
<!-- this whole xdebug thing is to disable and enalbe xdebug while running functional tests as it is much faster then-->
<!-- Load and unload xdebug on dev -->
<target name="toggleXdebug" description="Toggles the load of xdebug for php cli only.">
<php function="extension_loaded" returnProperty="xdebug_enabled">
<param value="xdebug"/>
</php>
<echo message="The current load state of xdebug is: ${xdebug_enabled}"/>
<if>
<equals arg1="${environment}" arg2="dev" />
<then>
<if>
<equals arg1="${xdebug_enabled}" arg2="true" />
<then>
<echo message="Trying to disable xdebug"/>
<phingcall description="Call unload xdebug" target="unloadXdebug" />
</then>
<else>
<echo message="Trying to enable xdebug"/>
<phingcall description="Call load xdebug" target="loadXdebug" />
</else>
</if>
</then>
<else>
<echo message="Not allowed to toggle xdebug in this environment."/>
</else>
</if>
</target>
<target name="unloadXdebug" description="Unloads xdebug" hidden="true">
<if>
<equals arg1="${environment}" arg2="dev" />
<then>
<exec command="sudo php5dismod xdebug"
description="Disable xdebug module"
checkreturn="true"
passthru="true" />
</then>
<else>
<echo message="Skipping xdebug-toggling as not in dev environment"/>
</else>
</if>
</target>
<target name="loadXdebug" description="Loads xdebug" hidden="true">
<if>
<equals arg1="${environment}" arg2="dev" />
<then>
<exec command="sudo php5enmod xdebug"
description="Enable xdebug module"
checkreturn="true"
passthru="true" />
</then>
<else>
<echo message="Skipping xdebug-toggling as not in dev environment"/>
</else>
</if>
</target>
<!-- end of xdebug enable/disable thing-->
<target name="configureApplication" description="Configures the drupal application">
<echo message="Configure Plan9 Server"/>
<if>
<isset property="enable.content.overwrite" />
<then>
<property name="yes-overwrite" value="y" />
</then>
<else>
<property name="yes-overwrite" value="n" />
</else>
</if>
<if>
<equals arg1="${yes-overwrite}" arg2="y" />
<then>
<phingcall target="dropDatabase" />
<phingcall target="createDatabase" />
<phingcall target="updateDatabaseSchema" />
<phingcall target="initializeGame" />
</then>
<else>
<echo message="Dont start to create database."/>
<echo message="Dont reinitialize game."/>
</else>
</if>
</target>
<target name="dropDatabase">
<echo message="Dropping database based on configuration for ${environment} environment."/>
<exec command="app/console doctrine:database:drop --force"
checkreturn="false" passthru="true"/>
</target>
<target name="createDatabase">
<echo message="Creating database based on configuration for ${environment} environment."/>
<exec command="app/console doctrine:database:create"
checkreturn="false" passthru="true"/>
</target>
<target name="updateDatabaseSchema">
<echo message="Updating database schema based on configuration for ${environment} environment."/>
<exec command="app/console doctrine:schema:update --force"
checkreturn="false" passthru="true"/>
</target>
<target name="copyConfigFilesWithReplacingPlaceholders" description="Copy configfiles from build/config to config">
<echo message="Copy ${path.base}/build/config/parameters.yml to ${path.base}/app/config/parameters.yml" />
<copy
file="${path.base}/build/config/parameters.yml"
tofile="${path.base}/app/config/parameters.yml"
overwrite="true"
>
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<target name="initializeGame">
<echo message="Initialize the game (resetting everything)"/>
<exec command="app/console plan9:initialize"
checkreturn="false" passthru="true"/>
</target>
<target name="info" description="Shows a info message " hidden="true">
<echo>
Targets:
build Cleans the workspace and builds the whole application including default fixtures.
rebuild Just rebuilds the whole app
unittest Starts a PHPUnit test run for all application test cases
Properties:
-Denvironment=XXX Set environment like dev, integration, live
-Denable.content.overwrite When building in a content save environment, force installation of fixtures
</echo>
<input propertyName="call.target" defaultValue="rebuild">Call target:</input>
<if>
<equals arg1="${call.target}" arg2="exit" />
<then>
<fail />
</then>
<else>
<phingcall target="${call.target}" />
</else>
</if>
</target>
<target name="cache-clear">
<echo message="Clearing Plan9 cache.." />
<exec command="app/console cache:clear --no-warmup" />
<echo message="Clearing Plan9 cache.." />
</target>
<target name="assetic-dump">
<echo message="Dumping the assetic prepared css and js" />
<exec command="app/console assetic:dump" />
</target>
<target name="assets-install">
<echo message="Installing the assets from the bundles in web with symlinks. (Better for development)" />
<exec command="app/console assets:install" />
</target>
<target name="clear-permissions">
<echo message="Clearing permissions for cache dir" />
<exec command="sudo chmod -R 0777 /tmp/cache" />
<echo message="Clearing permissions for logs dir" />
<exec command="sudo chmod -R 0777 /tmp/logs" />
</target>
</project>