forked from partkeepr/PartKeepr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
496 lines (429 loc) · 16.5 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
484
485
486
487
488
489
490
491
492
493
494
495
496
<?xml version="1.0" encoding="UTF-8"?>
<project name="partkeepr" default="build">
<property file="build.properties" />
<target name="pre-commit">
<jsllint haltonfailure="true">
<fileset dir="src/frontend">
<include name="**/*.js" />
</fileset>
</jsllint>
</target>
<!-- Cleans the output directories -->
<target name="clean">
<delete dir="reports" />
<delete dir="frontend" />
<delete dir="setup" />
<delete file="partkeepr.jsb3" />
</target>
<!-- Re-generates the proxies needed by Doctrine2 -->
<target name="create-orm-proxies">
<mkdir dir="data/" />
<exec command="doctrine orm:generate-proxies" passthru="true" />
</target>
<target name="compile-theme">
<exec dir="theme/sass" command="compass compile partkeepr.scss" passthru="true" />
<copy file="theme/css/partkeepr.css" tofile="src/frontend/css/partkeepr-theme.css" />
<copy file="theme/css/partkeepr.css" tofile="src/setup/css/partkeepr-theme.css" />
<copy todir="src/frontend/themes/images/">
<fileset dir="theme/themes/images/">
<include name="**/*" />
</fileset>
</copy>
<copy todir="src/setup/themes/images/">
<fileset dir="theme/themes/images/">
<include name="**/*" />
</fileset>
</copy>
</target>
<target name="git-update-submodules">
<exec command="git submodule sync" passthru="true" checkreturn="true" />
<exec command="git submodule init" passthru="true" checkreturn="true" />
<exec command="git submodule update" passthru="true" checkreturn="true" />
</target>
<!-- Build the end-user 'setup' directory -->
<target name="build-setup">
<mkdir dir="setup/" />
<echo>Copying extjs</echo>
<mkdir dir="setup/extjs/" />
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -ptgo
--include=/bootstrap.js
--include=/ext-all.js
--include=/ext-all-debug.js
--include=/ext-all-debug-w-comments.js
--exclude=*
${extjs.path}/* setup/extjs/" checkreturn="true" />
</then>
<else>
<copy overwrite="false" todir="setup/extjs/">
<fileset dir="${extjs.path}">
<include name="bootstrap.js" />
<include name="compatibility/ext3-core-compat.js" />
<include name="compatibility/ext3-compat.js" />
<include name="ext-all.js" />
<include name="ext-all-debug.js" />
<include name="ext-all-debug-w-comments.js" />
<include name="adapter/ext/ext-base.js" />
<include name="adapter/ext/ext-base-debug-w-comments.js" />
<include name="source/adapter/ext-base.js" />
</fileset>
</copy>
</else>
</if>
<echo>Copying Ext.ux.Wizard</echo>
<mkdir dir="setup/js/wizard" />
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a --delete 3rdparty/ext-wizard/Ext.ux.Wizard/ setup/js/wizard/" checkreturn="true" />
</then>
<else>
<copy overwrite="true" todir="setup/js/wizard">
<fileset dir="3rdparty/ext-wizard/Ext.ux.Wizard">
<include name="**" />
</fileset>
</copy>
</else>
</if>
<echo>Copying src/setup</echo>
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a src/setup/ setup/" checkreturn="true" />
</then>
<else>
<copy overwrite="true" todir="setup/">
<fileset dir="src/setup">
<include name="**" />
</fileset>
</copy>
</else>
</if>
</target>
<!-- Build the end-user 'frontend' directory -->
<target name="build-frontend">
<mkdir dir="frontend/" />
<echo>Copying 3rdparty/extjs - this may take up to a few minutes</echo>
<mkdir dir="frontend/extjs" />
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -ptgo -r
--include=/bootstrap.js
--include=/ext-all.js
--include=/ext-all-debug.js
--include=/ext-all-debug-w-comments.js
--include=/resources/***
--exclude=/*
${extjs.path}/* frontend/extjs/" checkreturn="true" />
</then>
<else>
<copy overwrite="false" todir="frontend/extjs/">
<fileset dir="${extjs.path}">
<include name="bootstrap.js" />
<include name="compatibility/ext3-core-compat.js" />
<include name="compatibility/ext3-compat.js" />
<include name="ext-all.js" />
<include name="ext-all-debug.js" />
<include name="ext-all-debug-w-comments.js" />
<include name="adapter/ext/ext-base.js" />
<include name="adapter/ext/ext-base-debug-w-comments.js" />
<include name="source/adapter/ext-base.js" />
<include name="resources/**" />
</fileset>
</copy>
</else>
</if>
<echo>Copying Ext Statusbar</echo>
<mkdir dir="frontend/js/Ext.ux/statusbar" />
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a --delete ${extjs.path}/examples/ux/statusbar/ frontend/js/Ext.ux/statusbar/" checkreturn="true" />
</then>
<else>
<copy overwrite="false" todir="frontend/js/Ext.ux/">
<fileset dir="${extjs.path}/examples/ux">
<include name="statusbar/**" />
</fileset>
</copy>
</else>
</if>
<echo>Copying Ext.tab.TabCloseMenu</echo>
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a ${extjs.path}/examples/ux/TabCloseMenu.js frontend/js/Ext.ux/" checkreturn="true" />
</then>
<else>
<copy overwrite="false" todir="frontend/js/Ext.ux/">
<fileset dir="${extjs.path}/examples/ux">
<include name="TabCloseMenu.js" />
</fileset>
</copy>
</else>
</if>
<echo>Copying Ext.ux.Wizard</echo>
<copy overwrite="false" todir="frontend/js/Ext.ux/">
<fileset dir="3rdparty/ext-wizard/Ext.ux.Wizard/">
<include name="Ext.ux.Wizard.Card.js" />
<include name="Ext.ux.Wizard.CardLayout.js" />
<include name="Ext.ux.Wizard.Header.js" />
<include name="Ext.ux.Wizard.js" />
</fileset>
</copy>
<echo>Copying Ext.ux.Exporter</echo>
<copy overwrite="false" todir="frontend/js/Ext.ux.Exporter/">
<fileset dir="3rdparty/Ext.ux.Exporter">
<include name="Base64.js" />
<include name="Formatter.js" />
<include name="Button.js" />
<include name="Exporter.js" />
<include name="downloadify.min.js" />
<include name="wikiFormatter/*" />
<include name="excelFormatter/*" />
<include name="csvFormatter/*" />
</fileset>
</copy>
<echo>Copying phpjs</echo>
<mkdir dir="frontend/js/org.phpjs.lib/" />
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a 3rdparty/phpjs/php.default.min.js frontend/js/org.phpjs.lib/" checkreturn="true" />
</then>
<else>
<copy overwrite="false" todir="frontend/js/org.phpjs.lib">
<fileset dir="3rdparty/phpjs/">
<include name="php.default.min.js" />
</fileset>
</copy>
</else>
</if>
<echo>Copying JS frontend</echo>
<if>
<isset property="build.fast" />
<then>
<exec dir="." passthru="true" command="rsync -a --exclude=.git src/frontend/ frontend/" checkreturn="true" />
</then>
<else>
<copy overwrite="true" todir="frontend/">
<fileset dir="src/frontend">
<include name="**" />
</fileset>
</copy>
</else>
</if>
<phingcall target="create-orm-proxies" />
<phingcall target="jsbuilder" />
</target>
<!-- Builds the frontend, regenerates the proxies and minifies the JS -->
<target name="build">
<phingcall target="git-update-submodules" />
<phingcall target="build-frontend" />
<phingcall target="build-setup" />
</target>
<!-- Fast build uses rsync instead of standard file copy -->
<target name="build-fast">
<condition property="build.fast">
<or>
<os family="mac" />
<os family="unix" />
</or>
</condition>
<fail unless="build.fast" message="Fast build only supported on Mac and Unix-like systems (rsync required)" />
<phingcall target="build" />
</target>
<!--
Creates a new PartKeepr release.
This task asks for the target version number, and then generates the zip and tbz2 archives out of it.
-->
<target name="release">
<propertyprompt propertyName="partkeepr.version" defaultValue="" promptText="Please enter the version number of the build to generate (e.g. 0.1)" />
<phingcall target="prepare-archiving" />
<phingcall target="set-version" />
<zip destfile="partkeepr-${partkeepr.version}.zip" basedir="${packagepath}" prefix="partkeepr-${partkeepr.version}/" />
<tar destfile="partkeepr-${partkeepr.version}.tbz2" compression="bzip2" basedir="${packagepath}" prefix="partkeepr-${partkeepr.version}/" />
</target>
<!--
Runs the build process, then copies the current working tree to a temporary directory (specified by ${packagepath})
while excluding stuff the end-user doesn't need (like .git directories, and some 3rdparty stuff).
-->
<target name="prepare-archiving">
<phingcall target="build" />
<delete quiet="true">
<fileset dir="${packagepath}" />
</delete>
<copy todir="${packagepath}" includeemptydirs="false">
<fileset dir=".">
<exclude name="3rdparty/extjs/**" />
<exclude name="3rdparty/phpjs/**" />
<exclude name="3rdparty/ext-wizard/**" />
<exclude name="theme/**/*" />
<exclude name="testing/**/*" />
<exclude name="util/**/*" />
<exclude name="src/frontend/**/*" />
<exclude name="src/setup/**" />
<exclude name="partkeepr.jsb3" />
<exclude name="partkeepr.jsb3.template" />
<exclude name="pre-commit.hook" />
<exclude name="RELEASE-TODO" />
<exclude name="build.properties" />
<exclude name="build.xml" />
<exclude name="cli-config.php" />
<exclude name="frontend/resources/fugue-icons/src/**/*" />
<exclude name="frontend/resources/fugue-icons/bonus/**/*" />
<exclude name="frontend/resources/fugue-icons/icons-shadowless/**/*" />
<exclude name="frontend/resources/fugue-icons/all.png" />
<exclude name="frontend/resources/fugue-icons/all-preview.png" />
<exclude name="frontend/resources/fugue-icons/all-shadowless.png" />
<exclude name=".git/**/*" />
<exclude name="3rdparty/doctrine-migrations/.git/**/*" />
<exclude name="frontend/resources/silkicons/.git/**/*" />
<exclude name="frontend/resources/flags/.git/**/*" />
<exclude name="frontend/resources/mimetypes/.git/**/*" />
<exclude name="frontend/resources/fugue-icons/.git/**/*" />
<exclude name="config.php" />
</fileset>
</copy>
<delete dir="${packagepath}/theme/" />
<delete dir="${packagepath}/testing/" />
<delete dir="${packagepath}/tests/" />
<delete dir="${packagepath}/src/frontend/" />
<delete dir="${packagepath}/src/setup/" />
<delete dir="${packagepath}/util/" />
<delete dir="${packagepath}/.git/" />
<delete dir="${packagepath}/3rdparty/doctrine-migrations/.git/" />
<delete dir="${packagepath}/frontend/resources/silkicons/.git/" />
<delete dir="${packagepath}/frontend/resources/flags/.git/" />
<delete dir="${packagepath}/frontend/resources/mimetypes/.git/" />
<delete dir="${packagepath}/frontend/resources/fugue-icons/.git/" />
<delete dir="${packagepath}/3rdparty/extjs/" />
<delete dir="${packagepath}/3rdparty/phpjs/" />
<delete dir="${packagepath}/3rdparty/ext-wizard/" />
<delete dir="${packagepath}/frontend/resources/fugue-icons/src/" />
<delete dir="${packagepath}/frontend/resources/fugue-icons/bonus/" />
<delete dir="${packagepath}/frontend/resources/fugue-icons/icons-shadowless/" />
</target>
<!--
Sets the version of the release inside PartKeeprVersion.php
-->
<target name="set-version">
<exec executable="sed">
<arg value="-i" />
<arg value="s/{V_GIT}/${partkeepr.version}/g" />
<arg value="${packagepath}/src/backend/PartKeepr/PartKeeprVersion.php" />
</exec>
</target>
<target name="nightly">
<phingcall target="prepare-archiving" />
<tstamp>
<format property="build.time" pattern="partkeepr-nightly-%Y%m%d" />
</tstamp>
<property name="partkeepr.version" value="${build.time}" />
<phingcall target="set-version" />
<zip destfile="${build.time}.zip" basedir="${packagepath}" prefix="partkeepr-nightly/" />
<tar destfile="${build.time}.tbz2" compression="bzip2" basedir="${packagepath}" prefix="partkeepr-nightly/" />
</target>
<!-- Builds the jsb3 file and build the minified JS files -->
<target name="jsbuilder">
<property name="jsbuilder.sources" value="--source=${project.basedir}/3rdparty/extjs/examples/ux/TabCloseMenu.js --source=${project.basedir}/src/frontend/js --source=${project.basedir}/3rdparty/ext-wizard/Ext.ux.Wizard/ --source=${project.basedir}/3rdparty/Ext.ux.Exporter/ --source ${project.basedir}/3rdparty/extjs/examples/ux/statusbar/"/>
<exec passthru="true" command="php partkeepr.php partkeepr:js-minify ${project.basedir}/frontend/js/partkeepr-debug.js ${jsbuilder.sources}" />
<exec passthru="true" command="php partkeepr.php partkeepr:js-minify ${project.basedir}/frontend/js/partkeepr.js --compress ${jsbuilder.sources}" />
</target>
<!-- Checks all JavaScript files for common mistakes. Requires JSLint from http://www.javascriptlint.com -->
<target name="jslint">
<jsllint>
<fileset dir="src/frontend">
<include name="**/*.js" />
</fileset>
</jsllint>
<jsllint>
<fileset dir="src/setup">
<include name="**/*.js" />
</fileset>
</jsllint>
</target>
<!-- Checks all PHP files for messy code. -->
<target name="phpmd">
<mkdir dir="reports/logs" />
<phpmd rulesets="codesize,unusedcode,design,naming">
<fileset dir="src/">
<include name="**/*.php" />
</fileset>
<formatter type="xml" outfile="reports/logs/pmd.xml" />
<formatter type="html" outfile="reports/pmd.html"/>
</phpmd>
</target>
<!-- Checks all PHP files for copy/paste code -->
<target name="phpcpd">
<mkdir dir="reports/logs" />
<phpcpd minTokens="30">
<fileset dir="src/">
<include name="**/*.php" />
</fileset>
<formatter type="pmd" outfile="reports/logs/pmd-cpd.xml" />
</phpcpd>
</target>
<target name="code-coverage">
<mkdir dir="reports/coverage/db" />
<mkdir dir="reports/phpunit" />
<coverage-setup database="reports/coverage/db/coverage.db">
<fileset dir="src/backend">
<include name="**/*.php" />
</fileset>
</coverage-setup>
<phpunit bootstrap="tests/bootstrap.php" haltonfailure="false" codecoverage="true" printsummary="true">
<batchtest>
<fileset dir="tests/">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter todir="reports/phpunit/" type="xml" />
<formatter type="clover" usefile="true" todir="reports/coverage/" />
</phpunit>
<phpunitreport infile="reports/phpunit/testsuites.xml" format="frames" todir="reports/phpunit" />
<coverage-report outfile="reports/coverage/db/coverage.xml">
<report todir="reports/coverage/" />
</coverage-report>
</target>
<target name="test">
<mkdir dir="reports/phpunit" />
<phpunit bootstrap="tests/bootstrap.php" haltonfailure="false" haltonerror="true" codecoverage="false" printsummary="true">
<formatter todir="reports/phpunit/" type="xml" />
<batchtest>
<fileset dir="tests/">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="plain" usefile="false" />
</phpunit>
<phpunitreport infile="reports/phpunit/testsuites.xml" format="frames" todir="reports/phpunit" />
</target>
<target name="test-setup">
<echo msg="Testing the installation..." />
<phpunit haltonfailure="true" codecoverage="false" printsummary="true">
<batchtest>
<fileset dir="setup/tests/">
<include name="*Test.php" />
</fileset>
</batchtest>
<formatter type="plain" usefile="false" />
</phpunit>
<echo msg="" />
<echo msg=" ***************************" />
<echo msg=" Setup Test Complete" />
<echo msg=" ***************************" />
<echo msg="" />
<echo msg=" No errors were found." />
<echo msg=" You may now proceed!" />
</target>
<target name="apigen">
<apigen source="${source.php}" destination="reports/api/" title="PartKeepr API Documentation" internal="true" deprecated="true" todo="true" charset="utf8" report="reports/logs/api-checkstyle.xml">
</apigen>
</target>
<target name="jenkins" depends="clean,phpmd,apigen,jslint,phpcpd,code-coverage">
</target>
</project>