-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.xml
560 lines (501 loc) · 22.1 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
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
<?xml version="1.0" encoding="UTF-8"?>
<project name="sockso" default="run" basedir=".">
<description>Builds, runs and packages Sockso</description>
<!--
#############
INIT/PROPS
#############
-->
<property file="sockso.properties" />
<property name="sockso.version" value="1.5.3" />
<property name="dir.build" value="build/app" />
<property name="dir.build.test" value="build/test" />
<property name="dir.dist" value="dist" />
<property name="dir.docs" value="docs" />
<property name="dir.docs.junit" value="${dir.docs}/junit" />
<property name="dir.src" value="src" />
<property name="dir.src.test" value="test" />
<property name="dir.lib" value="lib/std" />
<property name="dir.lib-dev" value="lib/dev" />
<property name="dir.lib-opt" value="lib/opt" />
<property name="dir.temp" value="ant-temp-dir" />
<property name="dir.resources" value="resources" />
<property name="dir.packages" value="packages" />
<property name="dir.scripts" value="scripts" />
<property name="dir.javadocs" value="${dir.docs}/javadocs" />
<property name="dir.www" value="www" />
<!-- set classpaths for jars -->
<fileset id="sockso.jars" dir=".">
<include name="${dir.lib}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="app.classpath" refid="sockso.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert pathsep=" " property="jar.classpath" refid="sockso.jars">
<map from="${basedir}/" to=" "/>
</pathconvert>
<!-- classpath for dev jars -->
<fileset id="sockso-dev.jars" dir=".">
<include name="${dir.lib-dev}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="dev.classpath" refid="sockso-dev.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<!-- classpath for optional jars -->
<fileset id="sockso-opt.jars" dir=".">
<include name="${dir.lib-opt}/*.jar" />
</fileset>
<pathconvert pathsep=":" property="opt.classpath" refid="sockso-opt.jars">
<map from="${basedir}/" to=""/>
</pathconvert>
<pathconvert pathsep=" " property="jar-opt.classpath" refid="sockso-opt.jars">
<map from="${basedir}/" to=" "/>
</pathconvert>
<property name="junit.classpath" value="${dir.build}:${dir.build.test}:${app.classpath}:${dev.classpath}:${opt.classpath}" />
<taskdef name="jamon"
classname="org.jamon.ant.JamonTask"
classpath="${dir.lib}/jamon-runtime-2.3.1.jar:${dir.lib-dev}/jamon-api-2.3.0.jar:${dir.lib-dev}/jamon-processor-2.3.2.jar:${dir.lib-dev}/jamon-anttask-2.3.1.jar" />
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler"
classpath="${dir.lib-dev}/jarbundler-2.1.0.jar" />
<taskdef name="testability"
classname="com.google.ant.TestabilityTask"
classpath="${dev.classpath}" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpath="${dev.classpath}" />
<target name="init">
<mkdir dir="${dir.dist}" />
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.build.test}" />
<mkdir dir="${dir.packages}" />
<if>
<not><available file="sockso.properties" /></not>
<then>
<copy file="sockso.properties-sample" tofile="sockso.properties" />
</then>
</if>
</target>
<!--
################
COMPILE/BUILD
################
-->
<target name="compile-templates" depends="init" description="compile jamon source files to java classes">
<delete dir="${dir.src}/com/pugh/mymusic/tmpl" />
<jamon destdir="${dir.src}" srcdir="templates" />
</target>
<!-- creates a file with some properties info -->
<target name="create-properties">
<!-- write app properties file -->
<echo file="src/com/pugh/sockso/Sockso.java">
package com.pugh.sockso;
public class Sockso {
public static final String VERSION = "${sockso.version}";
}
</echo>
</target>
<target name="compile" depends="create-properties,compile-templates" description="compiles the project to build dir">
<!-- then do compile -->
<javac srcdir="${dir.src}"
destdir="${dir.build}"
classpath="${app.classpath}:${opt.classpath}"
source="1.5"
target="1.5"
debug="${debug}"
includeantruntime="true">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>
<target name="resources" depends="init" description="compiles the resources">
<!-- compile stub file -->
<javac srcdir="${dir.resources}"
destdir="${dir.resources}"
source="1.5"
target="1.5"
includeantruntime="true" />
<!-- remove locale javascript files, we don't want to pack them -->
<delete>
<fileset dir="${dir.resources}/htdocs/js" includes="locale*.js" />
</delete>
<!-- pack javascript -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/pack-resources.php" />
<arg value="${sockso.version}" />
</exec>
<!-- create locale javascript files -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/create-locale-javascript.php" />
<arg value="${sockso.version}" />
</exec>
<!-- create locale index file -->
<exec executable="${php.exe}">
<arg value="${dir.scripts}/create-locale-index.php" />
<arg value="${sockso.version}" />
</exec>
<!-- build jar -->
<jar basedir="${dir.resources}" destfile="${dir.dist}/resources.jar">
<fileset dir="${dir.resources}">
<exclude name="**/*.java" />
<!-- TODO: exclude all javascript but the packed javascript file -->
</fileset>
</jar>
<!-- copy files to dist dir -->
<copy todir="${dir.dist}/resources">
<fileset dir="resources" />
</copy>
</target>
<target name="dist" depends="jars" description="builds the distributable files">
<copy todir="${dir.dist}">
<fileset dir="dist-files" />
</copy>
<copy todir="${dir.dist}/lib/std">
<fileset dir="${dir.lib}" />
</copy>
<!-- windows tray icon -->
<mkdir dir="${dir.dist}/icons" />
<copy file="${dir.resources}/icons/tray.ico" todir="${dir.dist}/icons" />
</target>
<target name="jars" depends="jar,resources" description="builds the sockso jar and resources"/>
<target name="clean-tests" description="cleans compiled tests classes">
<delete dir="${dir.build.test}" />
</target>
<target name="clean" depends="clean-tests" description="cleans the dist build">
<delete dir="${dir.build}" />
<delete dir="${dir.dist}" />
<delete dir="${dir.src}/com/pugh/sockso/templates" />
<delete dir="${dir.packages}" />
</target>
<target name="jar" depends="compile" description="builds the main jar file">
<jar file="${dir.dist}/sockso.jar" basedir="${dir.build}">
<include name="**/*.class" />
<manifest>
<attribute name="Built-By" value="${developer.name}" />
<attribute name="Main-class" value="com.pugh.sockso.Main" />
<attribute name="Class-Path" value="resources.jar ${jar.classpath} ${jar-opt.classpath}" />
</manifest>
</jar>
</target>
<target name="lint-js" description="run jslint on javascript files">
<exec executable="rhino" failonerror="true">
<arg value="scripts/lint.js" />
</exec>
</target>
<!--
#####################
DOCS/PACKAGING
#####################
-->
<target name="javadocs" description="generate sockso javadoc files">
<javadoc sourcepath="${dir.src}" destdir="${dir.javadocs}" classpath="${app.classpath}:${dev.classpath}:${opt.classpath}" />
</target>
<target name="package" depends="clean,dist,website" description="make packages from dist">
<mkdir dir="${dir.temp}" />
<move file="${dir.dist}" tofile="${dir.temp}/sockso-${sockso.version}" />
<!-- OSX.
1. create .app folder -->
<jarbundler dir="${dir.packages}"
name="sockso-${sockso.version}"
shortname="Sockso"
mainclass="com.pugh.sockso.Main"
icon="${dir.resources}/icons/sockso.icns"
version="${sockso.version}"
infostring="Sockso - Personal Music Server"
arguments="--resourcestype=jar"
jvmversion="1.5+">
<jarfileset dir="${dir.temp}">
<include name="**/*.jar" />
</jarfileset>
</jarbundler>
<!-- 2. create dmg's from .app folder -->
<exec executable="hdiutil">
<arg line="create -srcfolder ${dir.packages}/sockso-${sockso.version}.app ${dir.packages}/sockso-${sockso.version}.dmg"/>
</exec>
<copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-latest.dmg" />
<copy file="${dir.packages}/sockso-${sockso.version}.dmg" tofile="${dir.packages}/sockso-dev.dmg" />
<!-- 3. remove .app folder -->
<delete dir="${dir.packages}/sockso-${sockso.version}.app" />
<!-- we need the resources.jar files for the mac bundle, but not other packages -->
<delete file="${dir.temp}/sockso-${sockso.version}/resources.jar" />
<delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.class" />
<delete file="${dir.temp}/sockso-${sockso.version}/resources/ResourcesAnchor.java" />
<!-- make standard packages -->
<zip destfile="${dir.packages}/sockso-dev.zip" basedir="${dir.temp}" />
<zip destfile="${dir.packages}/sockso-latest.zip" basedir="${dir.temp}" />
<zip destfile="${dir.packages}/sockso-${sockso.version}.zip" basedir="${dir.temp}" />
<!-- @todo make 64bit windows archive -->
<!-- done, cleanup! -->
<move file="${dir.temp}/sockso-${sockso.version}" tofile="${dir.dist}" />
<delete dir="${dir.temp}" />
<!-- build optionals package -->
<zip destfile="${dir.packages}/sockso-optionals.zip" basedir="${dir.lib-opt}" />
</target>
<target name="website" description="updates the website (if it's configured) with information like current version">
<if>
<not><equals arg1="${website.path}" arg2="" /></not>
<then>
<property name="template" value="${website.path}/views/controllers/version/latest.tpl" />
<echo message="Updating website with latest version ${sockso.version}" />
<echo message="Template: ${template}" />
<echo file="${template}">${sockso.version}</echo>
</then>
</if>
</target>
<target name="optionals" description="includes optional components into the distribution">
<copy todir="${dir.dist}/lib/opt">
<fileset dir="${dir.lib-opt}" />
</copy>
</target>
<!--
##################
RUN/DEBUG
##################
-->
<target name="-runargs.init">
<condition property="run.opt.admin"
value="--admin" else="">
<isset property="run.arg.admin" />
</condition>
<condition property="run.opt.datadir"
value="--datadir=${run.arg.datadir}" else="">
<isset property="run.arg.datadir" />
</condition>
<condition property="run.opt.logtype"
value="--logtype=${run.arg.logtype}" else="">
<isset property="run.arg.logtype" />
</condition>
<condition property="run.opt.nogui"
value="--nogui" else="">
<isset property="run.arg.nogui" />
</condition>
<condition property="run.opt.resourcestype"
value="--resourcestype=${run.arg.resourcestype}" else="">
<isset property="run.arg.resourcestype" />
</condition>
<condition property="run.opt.ip"
value="--ip=${run.arg.ip}" else="">
<isset property="run.arg.ip" />
</condition>
<condition property="run.opt.locale"
value="--locale=${run.arg.locale}" else="">
<isset property="run.arg.locale" />
</condition>
<condition property="run.opt.dbtype"
value="--dbtype=${run.arg.dbtype}" else="">
<isset property="run.arg.dbtype" />
</condition>
<condition property="run.opt.dbhost"
value="--dbhost=${run.arg.dbhost}" else="">
<isset property="run.arg.dbhost" />
</condition>
<condition property="run.opt.dbuser"
value="--dbuser=${run.arg.dbuser}" else="">
<isset property="run.arg.dbuser" />
</condition>
<condition property="run.opt.dbpass"
value="--dbpass=${run.arg.dbpass}" else="">
<isset property="run.arg.dbpass" />
</condition>
<condition property="run.opt.dbname"
value="--dbname=${run.arg.dbname}" else="">
<isset property="run.arg.dbname" />
</condition>
<condition property="run.opt.ssl"
value="--ssl" else="">
<isset property="run.arg.ssl" />
</condition>
<condition property="run.opt.sslKeystore"
value="--sslKeystore=${run.arg.sslKeystore}" else="">
<isset property="run.arg.sslKeystore" />
</condition>
<condition property="run.opt.sslKeystorePassword"
value="--sslKeystorePassword=${run.arg.sslKeystorePassword}" else="">
<isset property="run.arg.sslKeystorePassword" />
</condition>
<condition property="run.opt.upnp"
value="--upnp" else="">
<isset property="run.arg.upnp" />
</condition>
</target>
<target name="run" depends="dist,optionals,-runargs.init" description="runs the project">
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
</java>
</target>
<target name="debug" depends="clean,dist,optionals,-runargs.init"
if="netbeans.home" description="runs the project in debug mode">
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,address=8888,suspend=n" />
</java>
</target>
<target name="profile" depends="dist,optionals,-runargs.init" if="netbeans.home">
<nbprofiledirect>
</nbprofiledirect>
<java jar="${dir.dist}/sockso.jar" dir="${dir.dist}/" fork="true" jvm="${ant.run.jvm}">
<sysproperty key="java.library.path" value="${dir.lib}" />
<arg value="${run.opt.admin}" />
<arg value="${run.opt.datadir}" />
<arg value="${run.opt.logtype}" />
<arg value="${run.opt.nogui}" />
<arg value="${run.opt.resourcestype}" />
<arg value="${run.opt.ip}" />
<arg value="${run.opt.locale}" />
<arg value="${run.opt.dbtype}" />
<arg value="${run.opt.dbhost}" />
<arg value="${run.opt.dbuser}" />
<arg value="${run.opt.dbpass}" />
<arg value="${run.opt.dbname}" />
<arg value="${run.opt.ssl}" />
<arg value="${run.opt.sslKeystore}" />
<arg value="${run.opt.sslKeystorePassword}" />
<arg value="${run.opt.upnp}" />
<jvmarg value="${profiler.info.jvmargs.agent}" />
</java>
</target>
<!--
##################
TESTING
##################
-->
<target name="compile-tests" description="compiles test classes">
<javac srcdir="${dir.src.test}"
destdir="${dir.build.test}"
classpath="${dir.build}:${app.classpath}:${dev.classpath}"
source="1.5"
target="1.5"
debug="on"
includeantruntime="true">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>
<!-- init before we do tests -->
<target name="init-tests">
<if>
<equals arg1="${mysql.enabled}" arg2="1" />
<then>
<sql driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://${mysql.host}"
userid="${mysql.user}"
password="${mysql.pass}"
classpath="${opt.classpath}"
onerror="continue">
<transaction src="test/data/mysql/drop.sql"/>
<transaction src="test/data/mysql/create.sql"/>
</sql>
</then>
</if>
</target>
<!-- the class to test needs to be specified on the command line by using:
-Dclass=FULL_CLASSNAME -->
<target name="test-single" depends="compile,compile-tests,init-tests" description="tests a particular class">
<fail unless="class">Must set property 'class'</fail>
<junit haltonfailure="true" fork="yes" dir="." showoutput="true">
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<classpath path="${junit.classpath}" />
<test name="${class}" todir="${dir.docs.junit}/results"/>
</junit>
</target>
<target name="test" depends="clean,compile,compile-tests,init-tests" description="run all tests and generate reports">
<delete dir="${dir.docs.junit}" />
<mkdir dir="${dir.docs.junit}" />
<mkdir dir="${dir.docs.junit}/html" />
<mkdir dir="${dir.docs.junit}/results" />
<junit haltonfailure="true" dir=".">
<classpath path="${junit.classpath}" />
<formatter type="plain" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${dir.docs.junit}/results">
<fileset dir="${dir.build.test}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${dir.docs.junit}">
<fileset dir="${dir.docs.junit}/results">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${dir.docs.junit}/html"/>
</junitreport>
</target>
<target name="testability" depends="clean,dist" description="runs the testability reports">
<testability
filter=""
resultfile="${dir.docs}/testability.result.html"
errorfile="${dir.docs}/testability.err.txt"
printdepth="2"
print="html"
mincost="1"
maxexcellentcost="50"
maxacceptablecost="100"
worstoffendercount="25"
whitelist="com.pugh.sockso."
cyclomatic="1"
global="10"
failproperty="testability.failproperty">
<classpath>
<fileset dir="${dir.dist}">
<include name="sockso.jar"/>
</fileset>
</classpath>
</testability>
</target>
<target name="test-all" depends="test,test-js" description="test everything"/>
<target name="test-js-server" description="starts the js test server">
<java jar="${dir.lib-dev}/JsTestDriver-${jstestdriver.version}.jar" fork="true">
<arg value="--port" />
<arg value="${jstestdriver.port}" />
</java>
</target>
<target name="test-js" description="runs the js tests">
<waitfor maxwait="1" maxwaitunit="second">
<socket server="localhost" port="${jstestdriver.port}"/>
</waitfor>
<!--
<condition property="tests" value="${tests}" else="all">
<isset property="tests" />
</condition>
-->
<java jar="${dir.lib-dev}/JsTestDriver-${jstestdriver.version}.jar" fork="true">
<arg value="--config" />
<arg value="test/js/jsTestDriver.conf" />
<arg value="--tests" />
<arg value="all" />
</java>
</target>
</project>