forked from unacms/una
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
393 lines (330 loc) · 15.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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="UNA" basedir="." default="test">
<property file="${project.basedir}/build.properties" override="true" />
<property name="build" value="0" override="yes" />
<property name="modules" value="" override="yes" />
<if>
<not><isset property="composer" /></not>
<then><property name="composer" value="${project.basedir}/tests/composer.phar" override="yes" /></then>
</if>
<if>
<not><isset property="php" /></not>
<then><property name="php" value="php" override="yes" /></then>
</if>
<if>
<not><isset property="db_name" /></not>
<then><property name="db_name" value="test" override="yes" /></then>
</if>
<if>
<not><isset property="db_user" /></not>
<then><property name="db_user" value="root" override="yes" /></then>
</if>
<if>
<not><isset property="db_password" /></not>
<then><property name="db_password" value="" override="yes" /></then>
</if>
<if>
<not><isset property="http_host" /></not>
<then><property name="http_host" value="localhost" override="yes" /></then>
</if>
<if>
<not><isset property="http_path" /></not>
<then><property name="http_path" value="/" override="yes" /></then>
</if>
<if>
<not><isset property="php_self" /></not>
<then><property name="php_self" value="${http_path}install/index.php" override="yes" /></then>
</if>
<if>
<and>
<not><isset property="doc_root" /></not>
<isset property="deploy_path" />
</and>
<then><property name="doc_root" value="${deploy_path}" override="yes" /></then>
</if>
<fileset dir="${project.basedir}" defaultexcludes="true" id="files_dist">
<include name="**/*" />
<exclude name="**/*.swp" />
<exclude name="inc/header*" />
<exclude name="build.xml" />
<exclude name="build.properties" />
<exclude name="storage/**/*" />
<exclude name="samples/**" />
<exclude name="scripts/**" />
<exclude name="tests/**" />
<exclude name="packages/**" />
<exclude name="upgrade/**" />
</fileset>
<fileset dir="${project.basedir}" defaultexcludes="true" id="doc_files">
<include name="**/*" />
<exclude name="**/*.swp" />
<exclude name="inc/header*" />
<exclude name="build.xml" />
<exclude name="build.properties" />
<exclude name="storage/**/*" />
<exclude name="samples/**" />
<exclude name="scripts/**" />
<exclude name="tests/**" />
<exclude name="packages/**" />
<exclude name="upgrade/**" />
<exclude name="cache/**" />
<exclude name="cache_public/**" />
<exclude name="logs/**" />
<exclude name="tmp/**" />
<exclude name="plugins/**" />
<exclude name="plugins_public/**" />
<exclude name="modules/boonex/sites/**" />
<exclude name="modules/boonex/membership_pricing/**" />
<exclude name="**/updates/**" />
</fileset>
<!-- ============================================ -->
<!-- Target: prepare -->
<!-- ============================================ -->
<target name="prepare">
<echo msg="Prepage: installing necessary components" />
<exec command="${php} ${composer} install" dir="${project.basedir}/tests" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: install -->
<!-- ============================================ -->
<target name="install">
<echo msg="Installing..." />
<if>
<not><isset property="install_base_dir" /></not>
<then><property name="install_base_dir" value="${project.basedir}" /></then>
</if>
<exec command="${php} cmd.php -m ${modules} --db_name=${db_name} --db_user=${db_user} --db_password=${db_password} --server_http_host=${http_host} --server_php_self=${php_self} --server_doc_root=${doc_root}" dir="${install_base_dir}/install" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- (DEFAULT) Target: test -->
<!-- ============================================ -->
<target name="test">
<echo msg="Testing..." />
<exec command="${php} vendor/bin/phpunit" dir="${project.basedir}/tests" checkreturn="true" />
</target>
<!-- ============================================ -->
<!-- Target: package -->
<!-- ============================================ -->
<target name="package" depends="clean">
<tstamp />
<property name="package_name" value="UNA-${DSTAMP}-${build}" override="yes" />
<property name="package_file" value="${package_name}.zip" />
<echo msg="Packaging ${package_file} file..." />
<mkdir dir="${project.basedir}/packages" />
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
<delete file="${project.basedir}/packages/${package_file}" quiet="true" />
<copy todir="${project.basedir}/packages/tmp/${package_name}">
<fileset refid="files_dist" />
</copy>
<zip destfile="${project.basedir}/packages/${package_file}">
<fileset dir="${project.basedir}/packages/tmp" defaultexcludes="true" />
</zip>
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
</target>
<!-- ============================================ -->
<!-- Target: package_upgrade -->
<!-- ============================================ -->
<target name="package_upgrade">
<tstamp />
<propertyprompt propertyName="version_from" promptText="Enter version to upgrade from" />
<propertyprompt propertyName="version_to" promptText="Enter version to upgrade to" />
<property name="package_name" value="UNA-Patch-v.${version_from}-to-v.${version_to}" override="yes" />
<property name="package_file" value="${package_name}.zip" />
<echo msg="Packaging ${package_file} file..." />
<mkdir dir="${project.basedir}/packages" />
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
<delete file="${project.basedir}/packages/${package_file}" quiet="true" />
<copy todir="${project.basedir}/packages/tmp/${package_name}">
<fileset dir="${project.basedir}/upgrade" defaultexcludes="true">
<include name="classes/**/*" />
<include name="BxDolUpgradeCron.php" />
<include name="files/${version_from}-*/**/*" />
<include name="files/*-${version_to}/**/*" />
</fileset>
</copy>
<zip destfile="${project.basedir}/packages/${package_file}">
<fileset dir="${project.basedir}/packages/tmp" defaultexcludes="true" />
</zip>
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
</target>
<!-- ============================================ -->
<!-- Target: package_all_modules -->
<!-- ============================================ -->
<target name="package_all_modules">
<property name="vendor" value="boonex" override="yes" />
<foreach param="module" target="package_module">
<fileset dir="${project.basedir}/modules/${vendor}">
<include name="*" />
</fileset>
</foreach>
</target>
<!-- ============================================ -->
<!-- Target: package_all_langs -->
<!-- ============================================ -->
<target name="package_all_langs">
<property name="vendor" value="boonex" override="yes" />
<foreach param="module" target="package_lang">
<fileset dir="${project.basedir}/modules/${vendor}">
<include name="*" />
</fileset>
</foreach>
<if>
<available file="${project.basedir}/modules/${vendor}/english/data/langs/system/en.xml" type="file" />
<then>
<mkdir dir="${project.basedir}/packages/en/system" />
<delete dir="${project.basedir}/packages/en/system" quiet="true" />
<echo msg="Copying lang file for system module..." />
<copy todir="${project.basedir}/packages/en/system">
<fileset dir="${project.basedir}/modules/${vendor}/english/data/langs/system" defaultexcludes="true" />
</copy>
</then>
</if>
</target>
<!-- ============================================ -->
<!-- Target: package_module -->
<!-- ============================================ -->
<target name="package_module">
<tstamp />
<property name="vendor" value="boonex" override="yes" />
<property name="module" value="antispam" override="yes" />
<if>
<available file="${project.basedir}/modules/${vendor}/${module}/install/config.php" type="file" />
<then>
<php expression="eval('include("${project.basedir}/modules/${vendor}/${module}/install/config.php"); return $aConfig["version"];')" returnProperty="module_version" />
<property name="package_name" value="${module}" />
<property name="package_file" value="${package_name}-v.${module_version}.zip" />
<echo msg="Packaging ${package_file} file..." />
<mkdir dir="${project.basedir}/packages" />
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
<delete file="${project.basedir}/packages/${package_file}" quiet="true" />
<copy todir="${project.basedir}/packages/tmp/${package_name}">
<fileset dir="${project.basedir}/modules/${vendor}/${module}" defaultexcludes="true">
<exclude name="updates/" />
</fileset>
</copy>
<zip destfile="${project.basedir}/packages/${package_file}">
<fileset dir="${project.basedir}/packages/tmp" defaultexcludes="true" />
</zip>
<delete dir="${project.basedir}/packages/tmp" quiet="true" />
</then>
</if>
</target>
<!-- ============================================ -->
<!-- Target: package_lang -->
<!-- ============================================ -->
<target name="package_lang">
<tstamp />
<property name="vendor" value="boonex" override="yes" />
<property name="module" value="antispam" override="yes" />
<if>
<and>
<available file="${project.basedir}/modules/${vendor}/${module}/install/config.php" type="file" />
<not><equals arg1="${module}" arg2="attendant" /></not>
<not><equals arg1="${module}" arg2="mapshow" /></not>
<not><equals arg1="${module}" arg2="una_mods" /></not>
<not><equals arg1="${module}" arg2="hosting_api" /></not>
<not><equals arg1="${module}" arg2="market_api" /></not>
</and>
<then>
<php expression="eval('include("${project.basedir}/modules/${vendor}/${module}/install/config.php"); return $aConfig["name"];')" returnProperty="module_name" />
<echo msg="Copying lang file for ${module} module..." />
<mkdir dir="${project.basedir}/packages" />
<mkdir dir="${project.basedir}/packages/en" />
<delete dir="${project.basedir}/packages/en/${module_name}" quiet="true" />
<copy todir="${project.basedir}/packages/en/${module_name}">
<fileset dir="${project.basedir}/modules/${vendor}/${module}/install/langs" defaultexcludes="true">
<exclude name="ru.xml" />
</fileset>
</copy>
</then>
</if>
</target>
<!-- ============================================ -->
<!-- Target: deploy -->
<!-- ============================================ -->
<target name="deploy">
<property name="deploy_path" value="/var/www" override="yes" />
<echo msg="Deploying to '${deploy_path}' folder..." />
<delete failonerror="true">
<fileset dir="${deploy_path}">
<include name="**/*" />
</fileset>
</delete>
<copy todir="${deploy_path}">
<fileset refid="files_dist" />
</copy>
<phingcall target="change_permissions">
<property name="files_path" value="${deploy_path}" />
</phingcall>
<phingcall target="install">
<property name="install_base_dir" value="${deploy_path}" />
</phingcall>
<delete dir="${deploy_path}/install" failonerror="true" />
</target>
<!-- ============================================ -->
<!-- Target: copy files for doc generation -->
<!-- ============================================ -->
<target name="copy_for_doc">
<property name="path" value="/tmp/doc_files" override="yes" />
<echo msg="Copying to '${path}' folder..." />
<delete failonerror="true">
<fileset dir="${path}">
<include name="**/*" />
</fileset>
</delete>
<copy todir="${path}">
<fileset refid="doc_files" />
</copy>
</target>
<!-- ============================================ -->
<!-- Target: change permissions -->
<!-- ============================================ -->
<target name="change_permissions">
<property name="files_path" value="${project.basedir}" override="yes" />
<echo msg="Change permissions in '${files_path}' folder..." />
<chmod file="${files_path}/cache" mode="0777" />
<chmod file="${files_path}/cache_public" mode="0777" />
<chmod file="${files_path}/logs" mode="0777" />
<chmod file="${files_path}/tmp" mode="0777" />
<chmod file="${files_path}/storage" mode="0777" />
<chmod file="${files_path}/plugins/ffmpeg/ffmpeg.exe" mode="0755" />
</target>
<!-- ============================================ -->
<!-- Target: clean -->
<!-- ============================================ -->
<target name="clean">
<echo msg="Cleaning..." />
<delete dir="${project.basedir}/tests/vendor" quiet="true" />
<delete includeemptydirs="true">
<fileset dir="${project.basedir}/cache">
<include name="**/*" />
<exclude name=".htaccess" />
</fileset>
</delete>
<delete includeemptydirs="true">
<fileset dir="${project.basedir}/cache_public">
<include name="**/*" />
<exclude name=".htaccess" />
</fileset>
</delete>
<delete includeemptydirs="true">
<fileset dir="${project.basedir}/logs">
<include name="**/*" />
<exclude name=".htaccess" />
<exclude name="clover.xml" />
<exclude name="phpcdp.xml" />
<exclude name="junit.xml" />
</fileset>
</delete>
<delete includeemptydirs="true">
<fileset dir="${project.basedir}/tmp">
<include name="**/*" />
<exclude name=".htaccess" />
</fileset>
</delete>
</target>
<target name="clean_install" depends="clean">
<echo msg="Install cleaning..." />
<delete file="${project.basedir}/inc/header.inc.php" quiet="true" />
</target>
</project>