-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
executable file
·477 lines (389 loc) · 16.9 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
<!--
~ ///////////////////////////////////////////////////////////////////////////////
~ // Copyright (c) 2009-2010, Rob Eden All Rights Reserved.
~ //
~ // This library is free software; you can redistribute it and/or
~ // modify it under the terms of the GNU Lesser General Public
~ // License as published by the Free Software Foundation; either
~ // version 2.1 of the License, or (at your option) any later version.
~ //
~ // This library is distributed in the hope that it will be useful,
~ // but WITHOUT ANY WARRANTY; without even the implied warranty of
~ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ // GNU General Public License for more details.
~ //
~ // You should have received a copy of the GNU Lesser General Public
~ // License along with this program; if not, write to the Free Software
~ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
~ ///////////////////////////////////////////////////////////////////////////////
-->
<project name="Trove4j" default="jar" basedir=".">
<description>Builds the Trove4j library</description>
<property name="Name" value="Trove"/>
<property name="name" value="trove"/>
<property name="year" value="2001-2014"/>
<property name="debug" value="on"/>
<property name="deprecation" value="on"/>
<property name="jar_name" value="trove.jar"/>
<property name="output.dir" value="output"/>
<property name="output.dest" value="${output.dir}/classes"/>
<property name="output.tests" value="${output.dir}/test_classes"/>
<property name="output.generator_classes" value="${output.dir}/generator_classes"/>
<property name="output.generated" value="${output.dir}/gen_src"/>
<property name="output.lib" value="${output.dir}/lib"/>
<property name="output.tests" value="${output.dir}/tests"/>
<property name="output.javadocs" value="${output.dir}/javadocs"/>
<property name="output.tmp" value="${output.dir}/tmp"/>
<property name="output.benchmarks" value="${output.dir}/benchmark_classes"/>
<property name="dist.root" value="${output.dir}/dist"/>
<property name="src" value="src"/>
<property name="generator_src" value="generator_src"/>
<property name="generator_test" value="generator_test"/>
<property name="test_src" value="test"/>
<property name="lib" value="lib"/>
<property name="idea" value="idea"/>
<property name="templates" value="templates"/>
<property name="jdk" value="1.7"/>
<!-- =============================================================== -->
<!-- The main target for building a release. This will perform a -->
<!-- "clean" followed by a "dist". -->
<!-- =============================================================== -->
<target name="release" depends="-init"
description="Do everything for a release: clean, build everything and test">
<antcall target="clean"/>
<antcall target="test"/>
<antcall target="dist"/>
<!-- .tar.gz file -->
<tar tarfile="${name}-${version}.tar" basedir="${dist.root}"/>
<gzip src="${name}-${version}.tar"
zipfile="${dist.root}/${name}-${version}.tar.gz"/>
<delete file="${name}-${version}.tar"/>
<!-- .zip file -->
<zip destfile="${dist.root}/${name}-${version}.zip" basedir="${dist.root}"
excludes="**/*.tar, **/*.tar.gz, **/*.tgz"/>
<antcall target="-maven-files"/>
</target>
<!-- =============================================================== -->
<!-- Clean all output -->
<!-- =============================================================== -->
<target name="clean" description="Remove all generated/compiled files">
<delete dir="${output.dir}"/>
</target>
<!-- =============================================================== -->
<!-- Generate classes based on templates. -->
<!-- =============================================================== -->
<target name="generate" depends="-build_generator"
description="Generate classes from templates">
<java classname="gnu.trove.generator.Generator" dir="${basedir}" fork="true">
<arg value="${templates}"/>
<arg value="${output.generated}"/>
<classpath>
<pathelement path="${output.generator_classes}"/>
</classpath>
</java>
</target>
<!-- =============================================================== -->
<!-- Compile the source directory. -->
<!-- =============================================================== -->
<target name="compile" depends="generate">
<javac destdir="${output.dest}"
classpath="${lib}/junit.jar"
debug="${debug}" target="${jdk}" source="${jdk}">
<src path="${src}"/>
<src path="${output.generated}"/>
</javac>
</target>
<!-- =============================================================== -->
<!-- Build the main jar. -->
<!-- =============================================================== -->
<target name="jar" depends="compile,-init">
<jar destfile="${output.lib}/${name}-${version}.jar">
<fileset dir="${output.dest}">
<exclude name="gnu/trove/benchmark/**"/>
<exclude name="gnu/trove/test/**"/>
<exclude name="gnu/trove/generate/**"/>
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Title" value="${Name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-URL"
value="https://bitbucket.org/robeden/trove/"/>
<attribute name="Sealed" value="false"/>
</manifest>
</jar>
</target>
<!-- =============================================================== -->
<!-- Places files to prepare for a release. -->
<!-- This build javadocs and copies misc. files. -->
<!-- =============================================================== -->
<target name="dist" depends="jar,javadoc"
description="Build all files for distribution">
<mkdir dir="${dist.root}"/>
<mkdir dir="${dist.root}/${version}"/>
<!-- Save build number -->
<antcall target="-print_buildNumber"/>
<!-- Copy source -->
<copy todir="${dist.root}/${version}/src">
<fileset dir="${src}"/>
</copy>
<copy todir="${dist.root}/${version}/test">
<fileset dir="${test_src}"/>
</copy>
<copy todir="${dist.root}/${version}/templates">
<fileset dir="${templates}"/>
</copy>
<copy todir="${dist.root}/${version}/generator_src">
<fileset dir="${generator_src}"/>
</copy>
<copy todir="${dist.root}/${version}/generator_test">
<fileset dir="${generator_test}"/>
</copy>
<copy todir="${dist.root}/${version}/idea">
<fileset dir="${idea}"/>
</copy>
<!-- Build a source jar -->
<jar destfile="${dist.root}/${version}/${name}-${version}-src.jar">
<fileset dir="${src}"/>
<fileset dir="${output.generated}"/>
</jar>
<!-- Copy javadocs & libs -->
<copy todir="${dist.root}/${version}">
<fileset dir="${output.dir}" includes="lib/**,javadocs/**"/>
</copy>
<copy todir="${dist.root}/${version}/lib" file="${lib}/junit.jar"/>
<!-- Misc. Files -->
<copy todir="${dist.root}/${version}">
<fileset dir="${basedir}" includes="*.txt"/>
</copy>
<copy todir="${dist.root}/${version}" file="build.xml"/>
</target>
<!-- =============================================================== -->
<!-- Create the javadocs. -->
<!-- =============================================================== -->
<target name="javadoc" depends="compile">
<mkdir dir="${output.javadocs}"/>
<javadoc destdir="${output.javadocs}"
maxmemory="256m"
packagenames="gnu.trove.*"
excludepackagenames="gnu.trove.impl.*"
author="false"
version="false"
windowtitle="${Name} ${fullVersion}"
doctitle="${Name} ${fullVersion}"
header="<a href="http://trove4j.sourceforge.net/">GNU Trove</a>">
<sourcepath>
<path location="src"/>
<path location="${output.generated}"/>
</sourcepath>
</javadoc>
</target>
<!-- =============================================================== -->
<!-- Compile and run the unit tests. -->
<!-- =============================================================== -->
<target name="test" depends="compile,-build_tests"
description="Compile unit tests and run them using JUnit.">
<copy todir="${output.tests}">
<fileset dir="${test_src}">
<include name="**/*.obj"/>
</fileset>
</copy>
<!-- Execute JUnit tests -->
<junit printsummary="no" showoutput="no"
errorProperty="test.failed" failureProperty="test.failed"
forkmode="once">
<classpath path="${output.tests}:${output.dest}:${lib}/junit.jar"/>
<classpath>
<pathelement location="${output.tests}"/>
<pathelement location="${output.dest}"/>
<pathelement path="${lib}\junit.jar"/>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
<batchtest fork="yes" todir="${output.dir}">
<formatter type="xml"/>
<fileset dir="${output.tests}/" includes="**/*Test.class"/>
</batchtest>
</junit>
<fail message="Tests failed. Check test output." if="test.failed"/>
</target>
<!-- =============================================================== -->
<!-- Run benchmarks. -->
<!-- =============================================================== -->
<target name="benchmark" depends="compile,-build_tests"
description="Run benchmark suite.">
<mkdir dir="${output.benchmarks}"/>
<javac destdir="${output.benchmarks}" debug="${debug}" source="${jdk}" target="${jdk}">
<src path="benchmarks/src"/>
<exclude name="gnu/trove/benchmark/colt/**"/>
<exclude name="gnu/trove/benchmark/compare/**"/>
<exclude name="gnu/trove/benchmark/trove2/**"/>
<classpath>
<pathelement location="${output.dest}"/>
<fileset dir="benchmarks/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</javac>
<!--<java classname="gnu.trove.benchmark.BenchmarkRunner" fork="true"-->
<!--output="${output.dir}/benchmarks-old.txt" failonerror="true">-->
<!--<classpath>-->
<!--<fileset dir="${lib}">-->
<!--<include name="*.jar"/>-->
<!--</fileset>-->
<!--<pathelement location="${output.dest}"/>-->
<!--<pathelement location="${output.generator_classes}"/>-->
<!--<pathelement location="${output.tests}"/>-->
<!--<pathelement location="${output.benchmarks}"/>-->
<!--</classpath>-->
<!--</java>-->
<echo message="Running benchmarks..."/>
<java classname="com.logicartisan.thrifty.benchmark.Runner" fork="true"
output="${output.dir}/benchmarks.txt" failonerror="true">
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="benchmarks/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${output.dest}"/>
<pathelement location="${output.generator_classes}"/>
<pathelement location="${output.tests}"/>
<pathelement location="${output.benchmarks}"/>
</classpath>
<arg value="-i"/>
<arg value="10"/> <!-- 10 iterations -->
<arg value="gnu.trove.benchmark.GetBenchmark"/>
<arg value="gnu.trove.benchmark.PutBenchmark"/>
<arg value="gnu.trove.benchmark.RemoveBenchmark"/>
<arg value="gnu.trove.benchmark.IterationBenchmark"/>
<arg value="gnu.trove.benchmark.ForEachBenchmark"/>
<arg value="gnu.trove.benchmark.ManyRemovalsBenchmark"/>
</java>
</target>
<!-- =============================================================== -->
<!-- Build maven files -->
<!-- =============================================================== -->
<target name="-maven-files" depends="-init">
<!-- Maven files -->
<mkdir dir="${dist.root}/maven"/>
<copy file="${dist.root}/${version}/${name}-${version}-src.jar"
tofile="${dist.root}/maven/trove4j-${version}-sources.jar"/>
<copy file="${dist.root}/${version}/lib/${name}-${version}.jar"
tofile="${dist.root}/maven/trove4j-${version}.jar"/>
<jar destfile="${dist.root}/maven/trove4j-${version}-javadoc.jar">
<fileset dir="${dist.root}/${version}/javadocs" includes="**"/>
</jar>
<copy file="resources/maven-manual-deploy-pom.xml"
tofile="${dist.root}/maven/trove4j-${version}.pom"/>
<replace file="${dist.root}/maven/trove4j-${version}.pom"
token="###VERSION###" value="${version}"/>
</target>
<!-- =============================================================== -->
<!-- Build generator classes. -->
<!-- =============================================================== -->
<target name="-build_generator" depends="-init">
<javac srcdir="${generator_src}"
destdir="${output.generator_classes}"
defaultexcludes="yes"
debug="${debug}"
source="${jdk}" target="${jdk}"/>
</target>
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<target name="-init" depends="-findVersion">
<echo message="Java version: ${java.version}"/>
<tstamp/>
<mkdir dir="${output.dir}"/>
<mkdir dir="${output.generator_classes}"/>
<mkdir dir="${output.dest}"/>
<mkdir dir="${output.tests}"/>
<mkdir dir="${output.generated}"/>
<mkdir dir="${output.generated}/gnu"/>
<mkdir dir="${output.generated}/gnu/trove"/>
<mkdir dir="${output.lib}"/>
<mkdir dir="${dist.root}"/>
</target>
<!-- =================================================================== -->
<!-- Targets related to benchmarks. -->
<!-- =================================================================== -->
<target name="-build_tests" depends="-init">
<javac destdir="${output.tests}" debug="${debug}" target="${jdk}" source="${jdk}">
<src path="${test_src}"/>
<exclude name="gnu/trove/benchmark/colt/**"/>
<exclude name="gnu/trove/benchmark/trove2/**"/>
<classpath>
<pathelement location="${lib}/junit.jar"/>
<pathelement location="${output.dest}"/>
</classpath>
</javac>
<!-- See if third party libraries are available -->
<available classname="cern.colt.map.OpenIntObjectHashMap"
property="colt.available">
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
</available>
<antcall target="-build_colt_benchmarks"/>
<available classname="gnu.trove.TIntObjectHashMap"
property="trove2.available">
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</classpath>
</available>
<antcall target="-build_trove2_benchmarks"/>
</target>
<target name="-build_colt_benchmarks" depends="-init" if="colt.available">
<javac destdir="${output.tests}" debug="${debug}" target="${jdk}" source="${jdk}">
<src path="${test_src}"/>
<include name="gnu/trove/benchmark/colt/**"/>
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<pathelement location="${output.dest}"/>
<pathelement location="${output.tests}"/>
</classpath>
</javac>
</target>
<target name="-build_trove2_benchmarks" depends="-init" if="colt.available">
<javac destdir="${output.tests}" debug="${debug}" target="${jdk}" source="${jdk}">
<src path="${test_src}"/>
<include name="gnu/trove/benchmark/trove2/**"/>
<classpath>
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
<pathelement location="${output.dest}"/>
<pathelement location="${output.tests}"/>
</classpath>
</javac>
</target>
<target name="-print_buildNumber" if="build.number">
<echo file="${dist.root}\trove.build" append="false">${version}</echo>
</target>
<!-- VERSION DISCOVERY -->
<target name="-findVersion"
depends="-version_versionNumber,-version_buildNumber,-version_none"/>
<target name="-version_versionNumber" if="version.number">
<property name="version" value="${version.number}"/>
<property name="fullVersion" value="${version.number}"/>
</target>
<target name="-version_buildNumber" if="build.number" unless="version.number">
<property name="version" value="${build.number}"/>
<property name="fullVersion" value="build ${build.number}"/>
</target>
<target name="-version_none">
<tstamp>
<format property="version" pattern="yyMMddHHmmss"/>
<format property="fullVersion" pattern="'build time' yyMMddHHmmss"/>
</tstamp>
</target>
</project>