forked from cross-solution/YAWIK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
485 lines (437 loc) · 20.3 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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<?xml version="1.0" encoding="UTF-8"?>
<project name="YAWIK" default="install">
<!-- build.properties can be set as an argument -->
<!-- ============================================ -->
<!-- Target: install -->
<!-- ============================================ -->
<target name="install" depends="check-requirements,init,generate-autoload-config" description="reads build.properties and generates config files">
<property name="target" value="config/autoload" override="true"/>
</target>
<!-- ============================================ -->
<!-- Target: Cleanup all -->
<!-- ============================================ -->
<target name="clean" description="removes build, log, cache, tmp, components and vendor dir">
<delete dir="${project.basedir}/build"/>
<delete dir="${project.basedir}/log"/>
<delete dir="${project.basedir}/cache"/>
<delete dir="${project.basedir}/tmp"/>
<delete dir="${project.basedir}/vendor"/>
<delete dir="${project.basedir}/components"/>
</target>
<!-- ============================================ -->
<!-- Target: prepare, creates log and cache dir -->
<!-- ============================================ -->
<target name="prepare" depends="symlinks">
<if>
<not>
<available file='${project.basedir}/log' type='dir' />
</not>
<then>
<mkdir dir="${project.basedir}/log"/>
<chmod file="${project.basedir}/log" mode="0777"/>
</then>
</if>
<if>
<not>
<available file='${project.basedir}/cache/DoctrineMongoODMModule/Hydrator' type='dir' />
</not>
<then>
<mkdir dir="${project.basedir}/cache/DoctrineMongoODMModule/Hydrator"/>
<chmod file="${project.basedir}/cache/DoctrineMongoODMModule/Hydrator" mode="0777"/>
</then>
</if>
<if>
<not>
<available file='${project.basedir}/cache/DoctrineMongoODMModule/Proxy' type='dir' />
</not>
<then>
<mkdir dir="${project.basedir}/cache/DoctrineMongoODMModule/Proxy"/>
<chmod file="${project.basedir}/cache/DoctrineMongoODMModule/Proxy" mode="0777"/>
</then>
</if>
<if>
<not>
<available file='${project.basedir}/build' type='dir' />
</not>
<then>
<mkdir dir="${project.basedir}/build"/>
<chmod file="${project.basedir}/build" mode="0777"/>
</then>
</if>
<if>
<not>
<available file='${project.basedir}/vendor' type='dir' />
</not>
<then>
<exec executable="php" passthru="true">
<arg value="composer.phar"/>
<arg value="install"/>
<arg value="--no-dev"/>
</exec>
</then>
</if>
</target>
<!-- ============================================ -->
<!-- Target: build -->
<!-- ============================================ -->
<target name="build" depends="prepare,translate"
description="build tgz and zip packages">
<delete dir="${project.basedir}/build"/>
<copy todir="${builddir}">
<fileset refid="core"/>
</copy>
<copy todir="${builddir}/public">
<fileset refid="awesomefonts"/>
</copy>
<mkdir dir="${builddir}/public/js/jquery-file-upload"/>
<copy todir="${builddir}/public/js/jquery-file-upload">
<fileset refid="blueimp"/>
</copy>
<mkdir dir="${builddir}/public/js/tinymce"/>
<copy todir="${builddir}/public/js/tinymce">
<fileset refid="tinymce"/>
</copy>
<copy file="${vendordir}/components/jquery/jquery.min.js" tofile="${builddir}/public/js/jquery.min.js"/>
<copy file="${vendordir}/twitter/typeahead.js/dist/bloodhound.min.js" tofile="${builddir}/public/Geo/js/bloodhound.min.js"/>
<copy file="${vendordir}/twitter/typeahead.js/dist/typeahead.jquery.min.js" tofile="${builddir}/public/Geo/js/typeahead.jquery.min.js"/>
<copy file="${vendordir}/twbs/bootstrap/dist/js/bootstrap.min.js" tofile="${builddir}/public/js/bootstrap.min.js"/>
<copy file="${vendordir}/ivaynberg/select2/select2.min.js" tofile="${builddir}/public/js/select2.min.js"/>
<copy file="${vendordir}/ivaynberg/select2/select2.css" tofile="${builddir}/public/css/select2.css"/>
<copy file="${vendordir}/ivaynberg/select2/select2-bootstrap.css" tofile="${builddir}/public/css/select2-bootstrap.css"/>
<copy file="${vendordir}/ivaynberg/select2/select2.png" tofile="${builddir}/public/css/select2.png"/>
<copy file="${vendordir}/ivaynberg/select2/select2-spinner.gif" tofile="${builddir}/public/css/select2-spinner.gif"/>
<copy file="${vendordir}/ivaynberg/select2/select2x2.png" tofile="${builddir}/public/css/select2x2.png"/>
<copy file="${project.basedir}/module/Geo/public/js/jquery.geolocationfield.js" tofile="${builddir}/public/Geo/js/jquery.geolocationfield.js"/>
<copy file="${project.basedir}/install.sh" tofile="${builddir}/install.sh"/>
<copy file="${project.basedir}/build.xml" tofile="${builddir}/build.xml"/>
<copy file="${project.basedir}/build.properties.dist" tofile="${builddir}/build.properties"/>
<mkdir dir="${builddir}/log"/>
<chmod file="${builddir}/log" mode="0777"/>
<mkdir dir="${builddir}/cache"/>
<chmod file="${builddir}/cache" mode="0777"/>
<mkdir dir="${builddir}/cache/DoctrineMongoODMModule/Hydrator"/>
<chmod file="${builddir}/cache/DoctrineMongoODMModule/Hydrator" mode="0777"/>
<mkdir dir="${builddir}/cache/DoctrineMongoODMModule/Proxy"/>
<chmod file="${builddir}/cache/DoctrineMongoODMModule/Proxy" mode="0777"/>
<mkdir dir="${builddir}/config/autoload"/>
<echo file="${builddir}/VERSION" append="false">${version}</echo>
<symlink link="build/YAWIK-${version-short}/public/Applications" target="../module/Applications/public" />
<symlink link="build/YAWIK-${version-short}/public/Auth" target="../module/Auth/public" />
<symlink link="build/YAWIK-${version-short}/public/Core" target="../module/Core/public" />
<symlink link="build/YAWIK-${version-short}/public/Jobs" target="../module/Jobs/public" />
<copy file="${project.basedir}/module/Core/view/layout/layout.phtml" toFile="${builddir}/module/Core/view/layout/layout.phtml" overwrite="true">
<filterchain>
<replaceregexp>
<regexp pattern='<version>.*?</version>' replace="${version}" multiline="true" />
</replaceregexp>
</filterchain>
</copy>
<echo msg="generate YAWIK-${version-short}.zip and YAWIK-${version-short}.tgz"/>
<exec dir="${builddir}/.." command="tar -czpf YAWIK-${version-short}.tgz YAWIK-${version-short}" logoutput="false"/>
<exec dir="${builddir}/.." command="zip -r YAWIK-${version-short}.zip YAWIK-${version-short}" logoutput="false"/>
</target>
<!-- ============================================ -->
<!-- Target: generate autoload config files -->
<!-- ============================================ -->
<target name="generate-autoload-config" depends="load-properties">
<property name="target" value="config/autoload" override="true"/>
<if>
<equals arg1="${username}" arg2="" trim="true"/>
<then>
<input message="Please enter an initial username:" propertyName="username"/>
</then>
</if>
<if>
<equals arg1="${password}" arg2="" trim="true"/>
<then>
<input message="Please enter an initial Password:" propertyName="password"/>
</then>
</if>
<if>
<istrue value="${facebook.enabled}"/>
<then>
<if>
<equals arg1="${facebook.appid}" arg2="" trim="true"/>
<then>
<input message="Please enter your facebook App ID:" propertyName="facebook.appid"/>
<input message="Please enter your facebook App Secret:" propertyName="facebook.secret"/>
</then>
</if>
</then>
</if>
<if>
<istrue value="${xing.enabled}"/>
<then>
<if>
<isset property="${xing.appid}"/>
<then>
<input message="Please enter your XING App ID:" propertyName="xing.appid"/>
<input message="Please enter your XING App Secret:" propertyName="xing.secret"/>
</then>
</if>
</then>
</if>
<if>
<istrue value="${linkedin.enabled}"/>
<then>
<if>
<isset property="${linkedin.appid}"/>
<then>
<input message="Please enter your LinkedIn App ID:" propertyName="linkedin.appid"/>
<input message="Please enter your LinkedIn App Secret:" propertyName="linkedin.secret"/>
</then>
</if>
</then>
</if>
<echo msg="generate config files in: ${target}"/>
<copy todir="${target}" overwrite="true">
<fileset dir="${project.basedir}/module">
<include name="**/**.dist"/>
<exclude name="YawikDemo**"/>
<exclude name="Jobs/**"/>
<exclude name="JobsDeutschland/**"/>
<exclude name="Organizations/**"/>
</fileset>
<mapper type="regexp" from="^(.*?)/([^/]+\.php)\.dist" to="\2"/>
<filterchain>
<replacetokens begintoken="%%" endtoken="%%">
<token key="mongo.host" value="${mongo.host}"/>
<token key="mongo.db" value="${mongo.db}"/>
<token key="mongo.user" value="${mongo.user}"/>
<token key="mongo.pass" value="${mongo.pass}"/>
<token key="mongo.port" value="${mongo.port}"/>
<token key="mail.from.name" value="${mail.from.name}"/>
<token key="mail.from.email" value="${mail.from.email}"/>
<token key="facebook.appid" value="${facebook.appid}"/>
<token key="facebook.secret" value="${facebook.secret}"/>
<token key="facebook.scope" value="${facebook.scope}"/>
<token key="facebook.enabled" value="${facebook.enabled}"/>
<token key="linkedin.appid" value="${linkedin.appid}"/>
<token key="linkedin.secret" value="${linkedin.secret}"/>
<token key="external.app.key" value="${external.app.key}"/>
<token key="external.app.prefix" value="${external.app.prefix}"/>
<token key="linkedin.enabled" value="${linkedin.enabled}"/>
<token key="linkedin.scope" value="${linkedin.scope}"/>
<token key="xing.appid" value="${xing.appid}"/>
<token key="xing.secret" value="${xing.secret}"/>
<token key="xing.scope" value="${xing.scope}"/>
<token key="xing.enabled" value="${xing.enabled}"/>
<token key="captcha.recapture.public_key" value="${captcha.recapture.public_key}"/>
<token key="captcha.recapture.private_key" value="${captcha.recapture.private_key}"/>
<token key="username" value="${username}"/>
<token key="password" value="${password}"/>
<token key="email" value="${email}"/>
<token key="role" value="${role}"/>
<token key="mail.first_login.subject" value="${mail.first_login.subject}"/>
<token key="auth.suffix" value="${auth.suffix}"/>
<token key="mail.develop.override_recipient" value="${mail.develop.override_recipient}" />
</replacetokens>
</filterchain>
</copy>
</target>
<!-- ============================================ -->
<!-- Target: translate -->
<!-- ============================================ -->
<target name="translate" depends="init,prepare,filesets" description="compiles all languages *.po files">
<echo msg="Compile locales ${locales} ..."/>
<foreach param="filename" absparam="absfilename" target="compile-po-file">
<mapper type="regexp" from="^(.*)\.po" to="\1"/>
<fileset refid="languages"/>
</foreach>
</target>
<target name="compile-po-file">
<echo msg="Translate ${filename}"/>
<exec command="msgfmt -cv -o ${project.basedir}/module/${filename}.mo ${absfilename}"
logoutput="true" dir="."/>
</target>
<!-- ============================================ -->
<!-- Target: docs -->
<!-- ============================================ -->
<target name="docs" depends="init,phpdoc" description="build api docs">
<tar destfile="build/YAWIK-docs-${version-short}.tgz"
basedir="${project.basedir}/docs"
compression="gzip" />
<echo msg="exec: zip -r YAWIK-${version-short}.zip YAWIK"/>
<exec dir="${builddir}/.." command="zip -r YAWIK-${version-short}.zip YAWIK" logoutput="false"/>
</target>
<!-- ============================================ -->
<!-- Target: symlinks -->
<!-- ============================================ -->
<target name="symlinks">
<symlink link="${project.basedir}/public/Core" target="${project.basedir}/module/Core/public" />
<symlink link="${project.basedir}/public/Applications" target="${project.basedir}/module/Applications/public" />
<symlink link="${project.basedir}/public/Auth" target="${project.basedir}/module/Auth/public" />
<symlink link="${project.basedir}/public/Jobs" target="${project.basedir}/module/Jobs/public" />
<symlink link="${project.basedir}/public/Geo" target="${project.basedir}/module/Geo/public" />
<symlink link="${project.basedir}/public/Settings" target="${project.basedir}/module/Settings/public" />
</target>
<!-- ============================================ -->
<!-- Target: phpdoc -->
<!-- ============================================ -->
<target name="phpdoc" depends="prepare" description="build api docs using phpdoc">
<exec command="rm -R ./tmp" dir="."/>
<exec command="phpdoc" dir="." passthru="true"/>
</target>
<target name="deploy-docs" description="publish API docs via rsync">
<property file="${project.basedir}/build.properties" />
<echo msg="deploy: rsync -r ${project.basedir}/docs/ ${deploy.ssh.user}@${deploy.ssh.host}:${deploy.docs.target}"/>
<exec command="rsync -rv ${project.basedir}/docs/ ${deploy.ssh.user}@${deploy.ssh.host}:${deploy.docs.target}" passthru="true"/>
</target>
<target name="deploy-builds" description="publish TGZ and ZIP packages via rsync">
<echo msg="deploy: rsync -r ${project.basedir}/build/ ${deploy.build.user}@${deploy.build.host}:${deploy.build.target}${version-short}"/>
<exec command="rsync -rv
${project.basedir}/build/YAWIK-${version-short}.* -l --exclude=YAWIK ${deploy.build.user}@${deploy.build.host}:${deploy.build.target}${version-short}" passthru="true"/>
</target>
<!-- ============================================ -->
<!-- Target: phpunit -->
<!-- ============================================ -->
<target name="phpunit" depends="prepare" description="run phpunit tests">
<exec command="vendor/phpunit/phpunit/phpunit -c ${project.basedir}/test/phpunit.xml"
logoutput="/dev/stdout"/>
</target>
<target name="filesets">
<!-- ============================================ -->
<!-- defines various filesets -->
<!-- ============================================ -->
<fileset id="core" dir="${project.basedir}">
<include name="module/**"/>
<include name="public/**"/>
<include name="bin/console"/>
<include name="config/config.php"/>
<include name="vendor/autoload.php"/>
<include name="vendor/composer/**"/>
<include name="vendor/zendframework/**"/>
<include name="vendor/hybridauth/**"/>
<include name="vendor/doctrine/**"/>
<include name="vendor/kriswallsmith/assetic/src/**"/>
<include name="LICENCE"/>
<include name="README"/>
<exclude name="public/js/*"/>
<exclude name="**/YawikDemo*/**"/>
<exclude name="**/CamMediaintown/**"/>
<exclude name="**/JobsDeutschland/**"/>
<exclude name="public/Applications"/>
<exclude name="public/Auth"/>
<exclude name="public/Core"/>
<exclude name="public/Geo"/>
<exclude name="public/Jobs"/>
<exclude name="public/Organizations"/>
<exclude name="**/*.po"/>
<exclude name="**/*.pot"/>
<exclude name="**/language/_annotated_strings.php"/>
<exclude name="public/fonts"/>
<exclude name="public/js/jquery-file-upload**"/>
<exclude name="public/css/select2**"/>
</fileset>
<fileset id="languages" dir="${project.basedir}/module">
<include name="**/**.po"/>
</fileset>
<fileset id="awesomefonts" dir="${vendordir}/fortawesome/font-awesome">
<include name="fonts/*"/>
</fileset>
<fileset id="blueimp" dir="${vendordir}/blueimp/jquery-file-upload/js">
<include name="jquery.iframe-transport.js"/>
<include name="jquery.fileupload.js"/>
<include name="vendor/jquery.ui.widget.js"/>
</fileset>
<fileset id="tinymce" dir="${vendordir}/tinymce/tinymce">
<include name="**/*"/>
</fileset>
</target>
<target name="init"
depends="load-properties, prepare"
unless="project.initialized">
<exec outputProperty="version" command="git describe --tags" dir="${project.basedir}"/>
<exec outputProperty="version-short"
command="git describe --tags --abbrev=0 | sed -E -n 's/v(.*)/\1/p'"
dir="${project.basedir}"/>
<exec outputProperty="external.app.key"
command="php -r 'echo uniqid(md5(microtime()));'"
dir="${project.basedir}"/>
<property name="builddir"
value="./build/${phing.project.name}-${version-short}"
override="false"/>
<property name="vendordir" value="./vendor" override="false"/>
<!-- Set property to prevent target from being executed multiple times -->
<property name="project.initialized" value="true"/>
</target>
<target name="load-properties">
<!-- first loop over all module properties files -->
<foreach param="dirname" absparam="absname" target="load-properties-subtask">
<fileset dir="module">
<type type="dir" />
<depth max="0" min="0" />
</fileset>
</foreach>
<!-- then read the global properties file -->
<property file="${project.basedir}/${build.properties}" />
</target>
<target name="load-properties-subtask">
<property name="properties" value="${absname}/config/build.properties" />
<available file="${properties}" type="file" property="build.properties.exists" />
<if>
<equals arg1="${build.properties.exists}" arg2="true" />
<then>
<echo>load ${properties}</echo>
<property file="${properties}" />
</then>
<else>
<echo>no ${properties} found. Check for a .dist file</echo>
<available file="${absname}/config/build.properties.dist" type="file" property="build.properties.dist.exists" />
<if>
<equals arg1="${build.properties.dist.exists}" arg2="true" />
<then>
<copy file="${absname}/config/build.properties.dist" tofile="${properties}" overwrite="true"/>
<property file="${properties}" />
</then>
</if>
<!-- If file doesn't exist -->
</else>
</if>
<available file="${absname}/build.xml" type="file" property="build.Exists" />
<if>
<isset property="build.Exists"/>
<then>
<phing phingfile="${absname}/build.xml" inheritAll="false"
inheritRefs="false" haltonfailure="true"/>
</then>
<else>
<echo>${absname}/build.xml not found</echo>
</else>
</if>
<if>
<istrue value="${YAWIK.bundled}"/>
<then>
<property name="modules[]" value="${dirname}" />
<echo>Bundled: ${YAWIK.bundled} Module: ${dirname}</echo>
</then>
</if>
</target>
<!-- ======================================================= -->
<!-- check requirements. A build.properties files is needed -->
<!-- ======================================================= -->
<target name="check-requirements">
<property name="build.properties" value="build.properties" override="false"/>
<if>
<not>
<available file="${build.properties}"/>
</not>
<then>
<echo level="warning">
the build.properties file does not exists at '${build.properties}'.
Use the build.properties.dist file as template
and adjust the configuration
</echo>
<php expression="exit();"/>
</then>
</if>
<if>
<not>
<os family="unix" />
</not>
<then>
<echo message="This build.xml is only tested on unix. Please give feedback, if this build.xml is not working on your OS" level="warning"/>
</then>
</if>
</target>
</project>