-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
524 lines (468 loc) · 18.4 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
<project name="mimprint" default="build">
<target name="init">
<property file="local.properties"/>
<property file="build.properties"/>
<property file="VERSION"/>
<property name="rel.subdir" value="${version.name}-${version.numberU}"/>
<property name="rel.dir" value="${release.dir}/${rel.subdir}" />
<property name="rel.jar" value="${rel.subdir}.jar" />
<property name="relbin.files"
value="README README.html VERSION LICENSE COPYRIGHT HISTORY \
mim mim.bat"/>
<property name="jarinst.files"
value="${src.dir}/jarinst/*.c ${src.dir}/jarinst/*.ini
${src.dir}/jarinst/*.inf ${src.dir}/jarinst/*.bat"/>
<property name="log4j.dir"
value="${net.dir}/log4j"/>
<property name="log4j.jar"
value="${log4j.dir}/log4j-${log4j.version}.jar"/>
<property name="jshortcut.dir"
value="${net.dir}/jshortcut/v${jshortcut.version}"/>
<property name="jshortcut.jar" value="${jshortcut.dir}/jshortcut.jar"/>
<property name="jshortcut.dll" value="${jshortcut.dir}/jshortcut.dll"/>
<property name="junit.dir"
value="${net.dir}/junit${junit.version}"/>
<property name="junit.jar" value="${junit.dir}/junit.jar"/>
<property name="hansel.dir"
value="${net.dir}/hansel-${hansel.version}"/>
<property name="hansel.jar" value="${hansel.dir}/lib/hansel.jar"/>
<property name="hansel-bcel.jar" value="${hansel.dir}/lib/bcel.jar"/>
<property name="scala.dir"
value="${net.dir}/scala/scala-current"/>
<property name="scala.compiler.jar"
value="${scala.dir}/lib/scala-compiler.jar"/>
<property name="scala.library.jar"
value="${scala.dir}/lib/scala-library.jar"/>
<property name="scalatest.version" value="1.0"/>
<property name="scalatest.dir"
value="${net.dir}/scala/scalatest-${scalatest.version}"/>
<property name="scalatest.jar"
value="${scalatest.dir}/scalatest-${scalatest.version}.jar"/>
<!-- Unit testing, things you might want to change -->
<property name="test.coverage" value=""/>
<property name="test.headlessarg" value="-Djava.awt.headless=true"/>
<property name="test.includes" value="**/Test*.java"/>
<property name="test.jvmarg" value=""/>
<!-- You should not have to change these values -->
<property name="testsrc.dir" value="testsrc"/>
<property name="testobj.dir" value="${build.dir}/testobj"/>
<property name="test.results.dir" value="${build.dir}/test/results"/>
<property name="test.reports.dir" value="${build.dir}/test/reports"/>
<property name="test.jar" value="${build.dir}/test.jar"/>
<property name="testresources.properties"
value="${testobj.dir}/net/jimmc/racer/TestResources.properties"/>
<!-- The classpath for compiling our java classes. -->
<path id="compile.classpath">
<pathelement location="${class.dir}"/>
<pathelement location="${jshortcut.jar}"/>
</path>
<!-- The classpath for compiling our scala classes. -->
<path id="scala.classpath">
<pathelement location="${scala.compiler.jar}"/>
<pathelement location="${scala.library.jar}"/>
<pathelement location="${class.dir}"/>
<pathelement location="${log4j.jar}"/>
</path>
<!-- The classpath for compiling our test java classes -->
<path id="testcompile.classpath">
<path refid="compile.classpath"/>
<path refid="scala.classpath"/>
<pathelement location="${scalatest.jar}"/>
<pathelement location="${testobj.dir}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hansel.jar}"/>
<pathelement location="${hansel-bcel.jar}"/>
</path>
<!-- The classpath for running our tests -->
<path id="test.classpath">
<path refid="compile.classpath"/>
<path refid="scala.classpath"/>
<pathelement location="${scalatest.jar}"/>
<pathelement location="${testobj.dir}"/>
<pathelement location="${junit.jar}"/>
<pathelement location="${hansel.jar}"/>
<pathelement location="${hansel-bcel.jar}"/>
</path>
<!-- The classpath for creating our scaladoc docs. -->
<path id="scaladoc.classpath">
<pathelement location="${scala.library.jar}"/>
<path refid="compile.classpath"/>
</path>
<!-- Define the scalac task -->
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath refid="scala.classpath"/>
</taskdef>
</target>
<target name="mkdirs" depends="init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${class.dir}"/>
<mkdir dir="${release.dir}"/>
<mkdir dir="${testobj.dir}"/>
</target>
<target name="build" depends="jar"/>
<target name="compile" depends="javac,scalac"/>
<target name="javac" depends="init,mkdirs">
<javac
srcdir="${src.dir}"
destdir="${class.dir}"
debug="${javac.debug}"
classpathref="compile.classpath"
source="1.4"
>
<include name="**/*.java"/>
<exclude name="**/*.old/**/*.java"/>
</javac>
</target>
<macrodef name="base-scalac">
<!-- fsc task is same as scalac, but uses cached "fast scala compiler" -->
<!-- To clear out the compiler cache, run "fsc -reset" -->
<attribute name="m.cp.name" default="scala.classpath"/>
<attribute name="m.src.dir" default="${src.dir}"/>
<attribute name="m.class.dir" default="${class.dir}"/>
<sequential>
<scalac
srcdir="@{m.src.dir}"
destdir="@{m.class.dir}"
addparams="-g:vars"
classpathref="@{m.cp.name}"
force="changed"
deprecation="on"
>
<include name="**/*.scala"/>
<exclude name="**/*.old/**/*.scala"/>
</scalac>
</sequential>
</macrodef>
<target name="scalac" depends="init,mkdirs,javac">
<base-scalac/>
</target>
<!-- Compile the test classes -->
<target name="testcompile" depends="testjavac,testscalac"
description="Compile all unit test java classes"/>
<!-- Compile the test java classes -->
<target name="testjavac" depends="init,mkdirs"
description="Compile all unit test java classes">
<javac
srcdir="${testsrc.dir}"
destdir="${testobj.dir}"
debug="${javac.debug}"
classpathref="testcompile.classpath"
source="1.4"
>
<include name="**/*.java"/>
<exclude name="**/*.old/**/*.java"/>
</javac>
</target>
<target name="testscalac" depends="init,build"
description="Compile the scala test files">
<base-scalac
m.cp.name="testcompile.classpath"
m.src.dir="${testsrc.dir}"
m.class.dir="${testobj.dir}" />
</target>
<!-- Create the default properties file from all of the props files -->
<target name="properties-default"
depends="init,check-properties-default,concat-properties-default"/>
<!-- See if the properties file is up to date -->
<target name="check-properties-default">
<uptodate property="properties-default-uptodate"
targetfile="${resources.properties}"
>
<srcfiles dir="${src.dir}"
includes="**/*.props"
excludes="**/*_*.props"
/>
<srcfiles dir="${src.dir}"
includes="net/jimmc/catprops/*.java"
/>
<srcfiles dir="." includes="build.xml" />
</uptodate>
</target>
<!-- Create the properties file if it is not up to date. -->
<target name="concat-properties-default"
unless="properties-default-uptodate">
<path id="prop-file-path">
<fileset dir="${src.dir}">
<include name="**/*.props"/>
<exclude name="**/*_*.props"/>
</fileset>
</path>
<property name="prop-files" refid="prop-file-path"/>
<java classname="net/jimmc/catprops/CatProps"
classpath="${class.dir}"
output="${resources.properties}.tmp"
fork="true"
failonerror="true"
>
<arg value="-sourcepath"/>
<arg line="${prop-files}"/>
</java>
<!-- Now that the props have been collected, replace the VERSION
and VDATE strings. -->
<copy file="${resources.properties}.tmp"
tofile="${resources.properties}">
<filterset begintoken="%" endtoken="%">
<filter token="VERSION" value="v${version.number}"/>
<filter token="VDATE" value="${version.date}"/>
</filterset>
</copy>
<delete file="${resources.properties}.tmp"/>
</target>
<!-- Create the test properties file from all of the test props files -->
<target name="testproperties"
depends="init,check-testproperties,concat-testproperties"/>
<!-- See if the test properties file is up to date -->
<target name="check-testproperties">
<uptodate property="testproperties-uptodate"
targetfile="${testresources.properties}"
>
<srcfiles dir="${testsrc.dir}" includes="**/*.props"/>
</uptodate>
</target>
<!-- Create the test properties file if it is not up to date. -->
<target name="concat-testproperties" unless="testproperties-uptodate">
<echo message="A test echo"/>
<!--
<echo destfile="${testobj.dir}/props.header" message="#Auto-generated"/>
<echo destfile="${testobj.dir}/props.header">
#This file is automatically created from the *.props files
#in various source directories.
</echo>
-->
<mkdir dir="${testobj.dir}/net/jimmc/racer"/>
<concat
destfile="${testresources.properties}.tmp"
>
<filelist dir="${testobj.dir}" files="props.header"/>
<fileset dir="${testsrc.dir}">
<include name="**/*.props"/>
<exclude name="**/*.old/**/*.props"/>
</fileset>
<!-- TBD - would be nice if we could get separators between
the files, like we had from the Makefile -->
</concat>
<!-- Now that the props have been collected, replace the VERSION
and VDATE strings. -->
<copy file="${testresources.properties}.tmp"
tofile="${testresources.properties}">
<filterset begintoken="%" endtoken="%">
<filter token="VERSION" value="v${versionNumber}"/>
<filter token="VDATE" value="${versionDate}"/>
</filterset>
</copy>
</target>
<target name="jar" depends="compile,properties-default"
description="Build the application">
<!-- Start by creating the jar file with all our classes. -->
<jar
jarfile="${mimprint.jar}"
basedir="${class.dir}"
>
<manifest>
<attribute name="Main-class" value="${main.class}"/>
<attribute name="Class-Path"
value="jRegistryKey.jar jshortcut.jar"/>
</manifest>
</jar>
<!-- Now add the image files from the source directory. -->
<zip
destfile="${mimprint.jar}"
basedir="${src.dir}"
update="true"
includes="**/*.gif **/*.png"
/>
</target>
<!-- Make the jar file with the test classes -->
<target name="testjar" depends="testcompile,testproperties"
description="Create the test.jar file">
<jar
jarfile="${test.jar}"
basedir="${testobj.dir}"
/>
</target>
<target name="test" depends="testinit,testjava,testscala"
description="Run the unit tests"/>
<target name="testinit" depends="jar,testjar">
<delete dir="${test.results.dir}"/>
<delete dir="${test.reports.dir}"/>
<mkdir dir="${test.results.dir}"/>
<mkdir dir="${test.reports.dir}"/>
</target>
<target name="testjava" depends="testinit">
<junit printsummary="true"
errorProperty="test.failed"
failureProperty="test.failed"
fork="yes">
<!-- Add JVM args to run with debugger enabled -->
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xnoagent"/>
<jvmarg line="-Djava.compiler=NONE ${test.jvmarg} ${test.headlessarg}"/>
<!-- we would put test.jvmarg and test.headlessarg
each in its own jvmarg, but we want
to be able to set them to blank, which doesn't work
properly when each is its own arg. -->
<formatter type="plain"/>
<formatter type="xml"/>
<classpath refid="test.classpath"/>
<sysproperty key="JR_TEST_COVERAGE"
value="${test.coverage}"/>
<batchtest todir="${test.results.dir}">
<fileset dir="${testsrc.dir}">
<include name="${test.includes}"/>
</fileset>
</batchtest>
</junit>
<!-- junitreport seems to be broken, so skip it...
<junitreport todir="${test.reports.dir}">
<fileset dir="${test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.reports.dir}"/>
</junitreport>
-->
<fail message="Test failures, see ${test.reports.dir}"
if="test.failed"/>
</target>
<target name="testscala" depends="testinit">
<pathconvert property="runscalatest.classpath"
refid="test.classpath" pathsep=":"/>
<property name="test.main.class" value="org.scalatest.tools.Runner"/>
<echo>scala -classpath ${runscalatest.classpath} ${test.main.class} -p ${testobj.dir} -o</echo>
<exec
executable="scala"
failonerror="true"
>
<arg line="-classpath ${runscalatest.classpath}"/>
<arg line="${test.main.class}"/>
<arg line="-p ${testobj.dir}"/>
<arg line="-o"/>
</exec>
</target>
<target name="testdebug" description="Run unit tests with suspend for debug">
<property name="test.debugjvmarg"
value="-Xrunjdwp:transport=dt_socket,address=2000,server=y,suspend=y"/>
<antcall target="test">
<param name="test.jvmarg" value="${test.debugjvmarg}"/>
</antcall>
</target>
<target name="clean" depends="init"
description="Remove all generated files">
<delete dir="${build.dir}"/>
<delete file="${mimprint.jar}"/>
</target>
<!-- Make the documentation -->
<target name="doc" depends="apidoc"
description="Compile all the documentation"/>
<target name="apidoc" depends="init"
description="Create the scaladoc documentation">
<uptodate targetfile="${apidoc.dir}/index.html"
property="apidoc-uptodate">
<srcfiles dir="${src.dir}"
includes="**/*.scala"
excludes="**/*.old/**/*.scala"/>
</uptodate>
<antcall target="create-apidoc"/>
</target>
<target name="create-apidoc" depends="init" unless="apidoc-uptodate">
<mkdir dir="${apidoc.dir}"/>
<scaladoc
srcdir="${src.dir}"
destdir="${apidoc.dir}"
classpathref="scaladoc.classpath"
>
<include name="**/*.scala"/>
<exclude name="**/*.old/**/*.scala"/>
</scaladoc>
</target>
<target name="coverage" description="Run unit tests with coverage">
<antcall target="test">
<param name="test.coverage" value="1"/>
</antcall>
</target>
<target name="all" depends="jar,doc,test"
description="Build all files and run all tests for release"/>
<target name="arch" depends="init"
description="Copy the reljar and README files to the Arch dir">
<property name="arch.version.dir"
value="${arch.dir}/v${version.number}"/>
<mkdir dir="${arch.version.dir}"/>
<copy file="${rel.jar}"
tofile="${arch.version.dir}/${rel.jar}"
preservelastmodified="true"/>
<copy file="README.html"
tofile="${arch.version.dir}/README-${version.numberU}.html"
preservelastmodified="true"/>
<chmod dir="${arch.version.dir}" includes="*" perm="-w"/>
</target>
<target name="gittag" depends="init"
description="Tag all files in git for the current release">
<echo message="Tagging files as ${version.name}-${version.number}"/>
<exec executable="git" failonerror="true" >
<arg line="tag -a -m 'Auto-tag version ${version.number}' ${version.name}-${version.number}"/>
</exec>
</target>
<target name="rel" depends="relbin,relsrc,relapidoc"
description="Create the release directory"/>
<target name="relbin" depends="init">
<mkdir dir="${rel.dir}"/>
<copy todir="${rel.dir}" flatten="true" preservelastmodified="true">
<fileset dir="." includes="${relbin.files}"/>
</copy>
<chmod dir="${rel.dir}" includes="mim" perm="+x"/>
<copy todir="${rel.dir}" file="${mimprint.jar}"
preservelastmodified="true"/>
<copy todir="${rel.dir}" file="${jshortcut.jar}"
preservelastmodified="true"/>
<copy todir="${rel.dir}" file="${jshortcut.dll}"
preservelastmodified="true"/>
<!-- Don't copy in the api doc, we deliver it in apidoc.zip ...
<copy todir="${rel.dir}/doc/api" preservelastmodified="true">
<fileset dir="${apidoc.dir}" includes="*"/>
</copy>
-->
<copy todir="${rel.dir}/templates" preservelastmodified="true">
<fileset dir="${templates.dir}" includes="**/*.mpr"/>
</copy>
</target>
<target name="relsrc" depends="init">
<property name="relsrc.includes"
value="README.build build.xml build.properties
${jarinst.files}
${src.dir}/**/*.java
${src.dir}/**/*.scala
${src.dir}/**/*.props
${src.dir}/**/*.html
${src.dir}/**/*.mf" />
<zip basedir="." destfile="${rel.dir}/src.zip"
includes="${relsrc.includes}"
excludes="**/*.old/**/*.*"
/>
</target>
<target name="relapidoc" depends="init">
<zip basedir="." destfile="${rel.dir}/apidoc.zip"
includes="${apidoc.dir}/**/*"
/>
</target>
<!-- Make the release jar file from the release directory -->
<target name="reljar" depends="init"
description=
"Create the distributable jar file from the release directory">
<!-- Start by creating a jar file with the release directory files -->
<jar basedir="${release.dir}" jarfile="${rel.jar}"
includes="${rel.subdir}/**">
<manifest>
<attribute name="Main-class"
value="net.jimmc.selfunzip.ZipSelfExtractor"/>
</manifest>
</jar>
<zip basedir="${class.dir}" destfile="${rel.jar}"
includes="net/jimmc/selfunzip/ZipSelfExtractor*.class"
update="true"
/>
<!-- Add the shortcut class for installing on windows. -->
<zip destfile="${rel.jar}" update="true">
<zipfileset src="${jshortcut.jar}"
includes="net/jimmc/jshortcut/JShellLink.class"/>
</zip>
</target>
</project>