This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
503 lines (425 loc) · 16 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
497
498
499
500
501
502
503
<?xml version="1.0" encoding="utf-8"?>
<!--
Requirements:
Pear:
- phpcs
-
PECL:
- xdebug
JavaScript:
- closure-compiler (npm install -g closure-compiler): Bindings to Google's Closure Compiler
- jshint (npm install -g jshint): A CLI for JSHint
- fixmyjs (npm install -g fixmyjs): Automatically fixes silly errors from jshint
-->
<project name="NeatlineMaps" default="build">
<property environment="ENV" />
<property name="build.dir" value="${basedir}/build" />
<property name="report.dir" value="${build.dir}/report" />
<property name="dist.dir" value="${build.dir}/dist" />
<property name="tmp.dir" value="${build.dir}/tmp" />
<property name="staging.dir" value="${build.dir}/tmp/NeatlineMaps" />
<property name="dir.views" value="views" />
<property name="project.name" value="NeatlineMaps" />
<property name="lang.dir" location="languages" />
<property name="core.pot" location="../../application/languages/Omeka.pot" />
<!-- Load the Ant-contrib to give us access to some very useful tasks! -->
<!-- the .jar file is located in the tools directory -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${build.dir}/tools/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="update-pot" description="Update the translation template.">
<property name="pot.file" location="${lang.dir}/template.pot"/>
<property name="pot.base" location="${lang.dir}/template.base.pot"/>
<tempfile property="pot.temp" suffix=".pot"/>
<tempfile property="pot.duplicates" suffix="-duplicates.pot" />
<apply executable="xgettext" relative="true" parallel="true" verbose="true">
<arg value="-L"/>
<arg value="php"/>
<arg value="--from-code=utf-8"/>
<arg value="-k__"/>
<arg value="--flag=__:1:pass-php-format"/>
<arg value="--omit-header"/>
<arg value="-F"/>
<arg value="-o"/>
<arg file="${pot.temp}"/>
<fileset dir="." includes="**/*.php **/*.phtml" excludes="tests/"/>
</apply>
<exec executable="msgcomm">
<arg value="--omit-header" />
<arg value="-o" />
<arg file="${pot.duplicates}" />
<arg file="${pot.temp}" />
<arg file="${core.pot}" />
</exec>
<exec executable="msgcomm">
<arg value="-u" />
<arg value="-o" />
<arg file="${pot.temp}" />
<arg file="${pot.temp}" />
<arg file="${pot.duplicates}" />
</exec>
<exec executable="msgcat">
<arg value="-o"/>
<arg file="${pot.file}"/>
<arg file="${pot.base}"/>
<arg file="${pot.temp}"/>
</exec>
<delete file="${pot.temp}" quiet="true" />
<delete file="${pot.duplicates}" quiet="true" />
</target>
<target name="build-mo" description="Build the MO translation files.">
<apply executable="msgfmt" dest="${lang.dir}" verbose="true">
<arg value="-o"/>
<targetfile />
<srcfile />
<fileset dir="${lang.dir}" includes="*.po"/>
<mapper type="glob" from="*.po" to="*.mo"/>
</apply>
</target>
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpunit,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="install-dependencies" description="Installs PEAR and node dependencies">
<!-- auto-discover channels -->
<exec executable="pear">
<arg value="config-set"/>
<arg value="auto_discover"/>
<arg value="1" />
</exec>
<exec executable="pear">
<arg value="install" />
<arg value="--alldeps" />
<arg value="pear.phpunit.de/PHPUnit" />
<arg value="PHP_CodeSniffer" />
<arg value="pear.pdepend.org/PHP_Depend" />
<arg value="pear.phpmd.org/PHP_PMD" />
<arg value="pear.phpqatools.org/phpqatools" />
<arg value="pear.netpirates.net/phpDox" />
</exec>
<exec executable="pecl">
<arg value="install" />
<arg value="xdebug"/>
</exec>
<echo>Installing npm packages...</echo>
<exec executable="npm">
<arg value="-g" />
<arg value="install"/>
<arg value="jshint" />
</exec>
</target>
<target name="update-dependencies" description="Updates testing dependencies">
<exec executable="pear">
<arg value="update-channels" />
</exec>
<exec executable="pear">
<arg value="upgrade-all" />
</exec>
<exec executable="pecl">
<arg value="upgrade-all" />
</exec>
<exec executable="npm">
<arg value="update"/>
<arg value="npm" />
<arg value="jshint" />
<arg value="-g" />
</exec>
</target>
<target name="tools-parallel"
description="Run tools in parallel">
<parallel threadcount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd-ci"/>
</sequential>
<antcall target="phpcpd"/>
<antcall target="phpcs-ci"/>
<antcall target="phploc"/>
<antcall target="phpdox"/>
</parallel>
</target>
<target name="clean" description="Cleanup build artifacts">
<delete dir="${build.dir}/api"/>
<delete dir="${build.dir}/code-browser"/>
<delete dir="${build.dir}/coverage"/>
<delete dir="${build.dir}/logs"/>
<delete dir="${build.dir}/pdepend"/>
<delete dir="${dist.dir}"/>
<delete dir="${staging.dir}" />
</target>
<target name="prepare" depends="clean"
description="Prepare for build">
<mkdir dir="${build.dir}/api"/>
<mkdir dir="${build.dir}/code-browser"/>
<mkdir dir="${build.dir}/coverage"/>
<mkdir dir="${build.dir}/logs"/>
<mkdir dir="${build.dir}/pdepend"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="jshint" description="Runs JSHint on JavaScript">
<echo message="Linting JavaScript..." />
<apply executable="jshint">
<fileset dir="${basedir}/views" excludes="**/*.min.js, **/*-min.js, **/build/**, **/simile/**, **/jquery*/**, **/taffy*.js. **/openlayers/**" includes="**/*.js" />
<srcfile/>
</apply>
</target>
<target name="minify-js" depends="_copy" description="Minifies JavaScript using Google's Closure Compiler">
<echo message="Minifying JavaScript..." />
<!-- work around for css files -->
<delete>
<fileset dir="${staging.dir}/${dir.views}/">
<include name="**/*.js"/>
</fileset>
</delete>
<apply executable="java" parallel="false">
<!--<fileset dir="${basedir}/${dir.views}/" excludes="**/*.min.js, **/spec/**," includes="**/*.js" />-->
<fileset dir="${basedir}/${dir.views}/" excludes="**/spec/**" includes="**/*.js"/>
<arg line="-jar" />
<arg path="${basedir}/build/tools/closure-compiler-v1346.jar" />
<!--<arg path="${basedir}/build/tools/yuicompressor-2.4.5.jar" />-->
<arg line="--js" />
<srcfile/>
<arg line="--compilation_level" />
<arg value="SIMPLE_OPTIMIZATIONS" />
<arg line="--js_output_file" />
<mapper type="glob" from="*.js" to="${staging.dir}/${dir.views}/*.js" />
<!--<mapper type="identity" /> -->
<targetfile/>
</apply>
</target>
<target name="minify-css" depends="_copy" description="Minifies CSS files">
<echo message="Minifying CSS files" />
<!-- work around for css files -->
<delete>
<fileset dir="${staging.dir}/${dir.views}/">
<include name="**/*.css"/>
</fileset>
</delete>
<apply executable="java" parallel="false">
<fileset dir="${basedir}/${dir.views}/" excludes="**/*.min.css" includes="**/*.css"/>
<arg line="-jar" />
<arg path="${build.dir}/tools/yuicompressor-2.4.5.jar" />
<srcfile/>
<arg line="-o" />
<mapper type="glob" from="*.css" to="${staging.dir}/${dir.views}/*.css" />
<!-- <mapper type="identity" /> -->
<targetfile />
</apply>
</target>
<target name="optimize-png" depends="_copy" description="Optimizes .png images">
<echo message="Optimizing pngs..." />
<echo message="This may tak a while, but everything else is already done." />
<echo message=" " />
<echo message="Running optipng on the .png files..." />
<!-- On *nix's and OS X, check for optipng and give a helpful message if it's not installed -->
<if>
<and>
<os family="unix" />
<available file="optipng" filepath="${ENV.PATH}" />
</and>
<then>
<!-- work around https://sourceforge.net/tracker/?func=detail&aid=2671422&group_id=151404&atid=780916 -->
<delete>
<fileset dir="${staging.dir}/${dir.views}/">
<include name="**/*.png"/>
</fileset>
</delete>
<apply executable="optipng" osfamily="unix">
<fileset dir="${basedir}/${dir.views}/" includes="**/*.png" />
<arg value="-quiet"/>
<arg value="-o7"/>
<arg value="-out"/>
<targetfile/>
<srcfile/>
<mapper type="glob" from="*.png" to="${staging.dir}/${dir.views}/*.png"/>
</apply>
</then>
<elseif>
<os family="unix" />
<then>
<echo message="*** optipng NOT INSTALLED. SKIPPING OPTIMIZATION OF PNGs." />
<echo message="*** Install optipng to enable png optimization." />
<echo message="*** For instructions see 'Dependencies' at: http://html5boilerplate.com/docs/#Build-script#dependencies" />
</then>
</elseif>
</if>
</target>
<target name="optimize-jpeg" depends="_copy" description="Optimizes .jpg images using jpegtan">
<echo message="Optimizing jpegs..." />
<var name="strip-meta-tags" value="all" />
<delete>
<fileset dir="${staging.dir}/${dir.views}/">
<include name="**/*.jpg"/>
</fileset>
</delete>
<!-- On *nix's and OS X, check for jpegtran and give a helpful message if it's not installed -->
<if>
<and>
<os family="unix" />
<available file="jpegtran" filepath="${ENV.PATH}" />
</and>
<then>
<apply executable="jpegtran" dest="${staging.dir}/${dir.views}/" osfamily="unix">
<fileset dir="${basedir}/${dir.views}/" includes="**/*.jpg" />
<arg value="-copy"/>
<arg value="${strip-meta-tags}"/>
<arg value="-optimize"/>
<arg value="-outfile"/>
<targetfile/>
<srcfile/>
<mapper type="glob" from="*.jpg" to="${staging.dir}/${dir.views}/"/>
<!-- you may want to flag optimized images. If so, do it here. Otherwise change this to type="identity" -->
<!--<mapper type="glob" from="*.jpg" to="*.jpg"/>-->
</apply>
</then>
<elseif>
<os family="unix" />
<then>
<echo message="*** jpegtran NOT INSTALLED. SKIPPING OPTIMIZATION OF JPEGs." />
<echo message="*** Install jpegtran to enable jpeg optimization." />
<echo message="*** For instructions see 'Dependencies' at: http://html5boilerplate.com/docs/#Build-script#dependencies" />
</then>
</elseif>
</if>
<apply executable="${basedir}/build/tools/jpegtran.exe" dest="./images/optimized" osfamily="windows">
<fileset dir="${basedir}/images" includes="**/*.jpg" />
<arg value="-copy"/>
<arg value="${strip-meta-tags}"/>
<arg value="-optimize"/>
<arg value="-outfile"/>
<targetfile/>
<srcfile/>
<mapper type="identity"/>
<!-- you may want to flag optimized images. If so, do it here. Otherwise change this to type="identity" -->
<!--<mapper type="glob" from="*.jpg" to="*.jpg"/>-->
</apply>
</target>
<target name="package" description="Build a package of this plugin"
depends="clean,minify-css, minify-js, optimize-png, optimize-jpeg">
<tstamp />
<property name="now" value="${DSTAMP}-${TSTAMP}" />
<property name="tar" value="${ant.project.name}-${now}.tar"/>
<property name="gzip" value="${tar}.gz" />
<echo message="Creating zipped tarball" />
<tar destfile="${dist.dir}/${tar}"
basedir="${tmp.dir}" />
<gzip zipfile="${dist.dir}/${gzip}" src="${dist.dir}/${tar}" />
<delete file="${dist.dir}/${tar}" />
<echo message="Creating zip file" />
<zip destfile="${dist.dir}/${ant.project.name}-${now}.zip"
basedir="${tmp.dir}" />
</target>
<target name="_copy" description="Copies files in to ${staging.dir}">
<echo message="Copying all files..." />
<mkdir dir="${staging.dir}" />
<copy todir="${staging.dir}">
<fileset dir="${basedir}/" excludes="**/build/**" />
</copy>
</target>
<target name="dist" description="Build a distribution page of the plugin" depends="_copy">
<!-- read ini file -->
<property name="tar" value="${project.name}.tar"/>
<property name="gzip" value="${tar}.gz" />
<tar destfile="${dist.dir}/${tar}.tar"
basedir="${staging.dir}/tmp"
excludes="test/**,spec**" />
<gzip zipfile="${dist.dir}/${gzip}" src="${tar}" />
<delete file="${dist.dir}/${tar}" />
</target>
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${basedir}/">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<target name="fixstyle" description="Automate the fixing of common JavaScript
errors">
<exec executable="fixjsstyle">
<arg value="--nojsdoc" />
<arg value="-r" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${build.dir}/logs/phploc.csv" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="pdepend"
description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${build.dir}/logs/jdepend.xml" />
<arg value="--jdepend-chart=${build.dir}/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${build.dir}/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="phpmd"
description="Perform project mess detection using PHPMD">
<exec executable="phpmd">
<arg path="${basedir}/" />
<arg value="text" />
<arg value="${build.dir}/phpmd.xml" />
</exec>
</target>
<target name="phpmd-ci"
description="Perform project mess detection using PHPMD">
<exec executable="phpmd">
<arg path="${basedir}/" />
<arg value="xml" />
<arg value="${build.dir}/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${build.dir}/logs/pmd.xml" />
</exec>
</target>
<target name="phpcs"
description="Find coding standard violations using PHP_CodeSniffer">
<exec executable="phpcs">
<arg value="--standard=${build.dir}/phpcs.xml" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="phpcs-ci"
description="Find coding standard violations using PHP_CodeSniffer">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${build.dir}/logs/checkstyle.xml" />
<arg value="--standard=${build.dir}/phpcs.xml" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${build.dir}/logs/pmd-cpd.xml" />
<arg path="${basedir}/" />
</exec>
</target>
<target name="phpdox" description="Generate API documentation using phpDox">
<exec executable="phpdox" />
</target>
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="true"/>
</target>
<target name="phpcb"
description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${build.dir}/logs" />
<arg value="--source" />
<arg path="${basedir}/" />
<arg value="--output" />
<arg path="${build.dir}/code-browser" />
</exec>
</target>
<target name="usage">
<echo message="Type ant -p to list all the targets available in this build script." />
</target>
</project>