-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
363 lines (299 loc) · 14.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
<?xml version="1.0"?>
<!--
Copyright (c) 2023 to 2024, Damon Hart-Davis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- ======================================================================= -->
<!-- Stand-alone 'daemon' app. -->
<!-- ======================================================================= -->
<!-- Use Ant 1.6 or newer. -->
<!-- All code runs under JDK 18. -->
<!--
Expects JUnit 3.8.1 or newer.
-->
<project name="statsHouse" default="init" basedir=".">
<property name="app.name" value="statsHouse"/>
<property name="app.version.major" value="5"/>
<property name="app.version.minor" value="3"/>
<property name="app.version.micro" value="4"/>
<property name="app.version" value="${app.version.major}.${app.version.minor}.${app.version.micro}"/>
<!-- Version excluding the "micro" portion, thus reflecting only significant API/functionality changes. -->
<property name="app.version.notmicro" value="${app.version.major}.${app.version.minor}"/>
<!-- Optimised JAR -->
<property name="dist.jar" value="${app.name}-${app.version}.jar"/>
<!-- Optimised minified JAR for core statsHouse only -->
<property name="shdist.jar" value="${app.name}-${app.version}.min.jar"/>
<!-- Target/minimum JDK/JSE version for build and run. -->
<property name="JDKVER" value="18"/>
<!-- Stub names, used in source and output dirs and package names. -->
<!-- This is core code. -->
<property name="core" value="core"/>
<!-- The base dir of the Java source. -->
<property name="jsrc.base.dir" value="javasrc"/>
<property name="core.src.dir" value="${jsrc.base.dir}"/>
<!-- The base dir of the Java unit tests. -->
<property name="test.src.dir" value="test/javasrc/localtest"/>
<property name="dirsuffix.dbg" value="_D"/>
<property name="dirsuffix.opt" value="_O"/>
<property name="build.dir.base" value="out"/>
<property name="build.dir.dbg" value="../${build.dir.base}${dirsuffix.dbg}"/>
<property name="build.dir.opt" value="../${build.dir.base}${dirsuffix.opt}"/>
<!-- Build dir for common (non-opt, non-dbg) items. -->
<property name="build.dir.cmn" value="../${build.dir.base}_C"/>
<!-- General temporary work directory. -->
<property name="tmp.workdir" value="work.tmp"/>
<!-- Basic class path we compile against; includes any external libs. -->
<!-- <property name="cp.common.basic" value="lib/example.jar"/> -->
<property name="cp.common.basic" value=""/>
<!-- Provided in debug/non-debug versions. -->
<!-- Expects cp.J2EEAPI to contain a classpath fragment for the J2EE API. -->
<property name="cp.dbg.basic" value="${cp.common.basic}"/>
<property name="cp.opt.basic" value="${cp.common.basic}"/>
<!-- Class path for libs that may run against; includes any external (non-test) libs. -->
<!-- <property name="cp.common.rt" value="lib/rtexample1.jar:lib/rtexample2.jar"/> -->
<property name="cp.common.rt" value=""/>
<!-- Test-only library area. -->
<property name="test.lib.dir" value="test/lib"/>
<!-- JUnit JAR name -->
<property name="test.junit.jar" value="junit-4.13.2.jar"/>
<!--Place where javadoc is built. -->
<property name="javadoc.dir" value="${build.dir.cmn}/javadoc"/>
<!-- ProGuard static optimiser/shrunker. -->
<property name="pg.dir" value="../proguard-7.4.2" />
<taskdef resource="proguard/ant/task.properties"
classpath="${pg.dir}/lib/proguard-ant.jar" />
<!-- General initialisation target. -->
<target name="init">
<tstamp/>
</target>
<!-- =================================================================== -->
<!-- Prepares the core build directories, debug and optimised -->
<!-- =================================================================== -->
<!-- DBG -->
<target name="core.prepare.dbg.testuptodate">
<!-- Claim that the JAR target is up-to-date if its source files are. -->
<uptodate property="core.jar.dbg.uptodate"
targetfile="${build.dir.dbg}/${core.jar}">
<srcfiles dir="${core.src.dir}" includes="**/*.java"/>
<!-- <srcfiles dir="${ai.src.dir}" includes="**/*.java"/> -->
<!-- <srcfiles dir="${tp.src.dir}" includes="**/*.java"/> -->
</uptodate>
</target>
<target name="core.prepare.dbg"
depends="init,core.prepare.dbg.testuptodate"
unless="core.jar.dbg.uptodate">
<delete file="${build.dir.dbg}/${core.jar}" quiet="true"/>
<mkdir dir="${build.dir.dbg}/${tmp.workdir}/${core}"/>
<delete file="${build.dir.dbg}/.tmp.${core.jar}" quiet="true"/>
</target>
<!-- OPT -->
<!-- This is extra strict and cleans everything out before starting. -->
<target name="core.prepare.opt"
depends="init">
<!-- Make sure that the working dir is clear of cached state. -->
<delete dir="${build.dir.opt}" quiet="true"/>
<mkdir dir="${build.dir.opt}/${tmp.workdir}/${core}"/>
<delete file="${build.dir.opt}/.tmp.${core.jar}" quiet="true"/>
</target>
<!-- =================================================================== -->
<!-- Compiles the core source code, debug and optimised -->
<!-- =================================================================== -->
<!-- DBG -->
<target name="core.compile.dbg"
depends="core.prepare.dbg"
unless="core.jar.dbg.uptodate">
<javac srcdir="${core.src.dir}"
destdir="${build.dir.dbg}/${tmp.workdir}/${core}"
classpath="${cp.dbg.basic}"
includeantruntime="false"
debug="on"
deprecation="on"
optimize="off">
<compilerarg value="-Xlint"/>
<include name="**/*.java"/>
</javac>
</target>
<!-- OPT -->
<target name="core.compile.opt"
depends="core.prepare.opt">
<javac srcdir="${core.src.dir}"
destdir="${build.dir.opt}/${tmp.workdir}/${core}"
classpath="${cp.opt.basic}"
includeantruntime="false"
debug="on"
deprecation="on"
optimize="on">
<compilerarg value="-Xlint"/>
<include name="**/*.java"/>
</javac>
</target>
<!-- =================================================================== -->
<!-- JARs the core source code, debug and optimised -->
<!-- =================================================================== -->
<!-- DBG -->
<target name="core.jar.dbg"
depends="core.compile.dbg"
unless="core.jar.dbg.uptodate"
description="builds the debug core classes JAR shared by all other app components">
<jar jarfile="${build.dir.dbg}/${core.jar}"
basedir="${build.dir.dbg}/${tmp.workdir}/${core}">
<include name="org/hd/**/*.class"/>
<manifest>
<attribute name="Main-Class" value="org.hd.d.statsHouse.Main"/>
<!-- <attribute name="Class-Path" value="${cp.common.basic}"/> -->
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Implementation-Version" value="${app.version}"/>
</manifest>
</jar>
</target>
<!-- OPT -->
<target name="core.jar.opt"
depends="core.compile.opt"
description="builds the optimised/release core classes JAR shared by all other app components">
<jar jarfile="${build.dir.opt}/${dist.jar}"
basedir="${build.dir.opt}/${tmp.workdir}/${core}">
<!-- <zipgroupfileset dir="libs" includes="*.jar" excludes=""/> -->
<include name="org/hd/**/*.class"/>
<manifest>
<attribute name="Main-Class" value="org.hd.d.statsHouse.Main"/>
<!-- <attribute name="Class-Path" value="${cp.common.basic}"/> -->
<attribute name="Implementation-Title" value="${app.name}"/>
<attribute name="Implementation-Version" value="${app.version}"/>
</manifest>
</jar>
<echo message="Release JAR now at ${build.dir.opt}/${dist.jar} ..." />
</target>
<!-- Super-optimised and shrunk org.hd.d.statsHouse.Main JAR -->
<target name="core.jar.shMainsuperopt"
depends="core.jar.opt"
description="builds the shrunk optimised/release org.hd.d.statsHouse.Main JAR">
<proguard
verbose="true">
<!-- -printconfiguration -->
-injars ${build.dir.opt}/${dist.jar}
-outjars ${build.dir.opt}/${shdist.jar}
-libraryjars ${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)
-libraryjars ${java.home}/jmods/java.desktop.jmod(!**.jar;!module-info.class)
<!--
-libraryjars ${cp.opt.basic}
-libraryjars ${cp.common.rt}
-->
-keep public class org.hd.d.statsHouse.Main {
public *;
}
<!-- Makes the enum handling a little simpler! -->
-keep public class org.hd.d.statsHouse.generic.Style {
public *;
}
<!-- Build a few times, run many: thus worth extra optimisation effort here... -->
-optimizationpasses 5
-allowaccessmodification
-dontobfuscate <!-- leave all class/method names etc for easiest debugging -->
-keepattributes SourceFile,LineNumberTable <!-- Keep minimum for exception debugging. -->
</proguard>
<echo message="Release org.hd.d.statsHouse.Main JAR now at ${build.dir.opt}/${shdist.jar} ..." />
</target>
<!-- =================================================================== -->
<!-- Tests the core source code, debug and optimised -->
<!-- =================================================================== -->
<!-- OPT -->
<target name="core.test.opt"
depends="core.compile.opt">
<!-- Compile the test cases -->
<mkdir dir="${build.dir.opt}/${tmp.workdir}/test"/>
<javac srcdir="${test.src.dir}"
destdir="${build.dir.opt}/${tmp.workdir}/test"
classpath="${build.dir.opt}/${tmp.workdir}/core;${cp.opt.basic};${test.lib.dir}/${test.junit.jar}"
includeantruntime="false"
debug="on"
deprecation="on"
optimize="on">
<include name="**/*.java"/>
</javac>
<mkdir dir="${build.dir.opt}/testResults"/>
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement path="${test.lib.dir}/${test.junit.jar}"/>
<pathelement location="${build.dir.opt}/${tmp.workdir}/core"/>
<pathelement location="${build.dir.opt}/${tmp.workdir}/test"/>
</classpath>
<formatter type="plain"/>
<!--
<test name="localtest.TestMisc" haltonfailure="yes" outfile="${build.dir.opt}/junit_result">
<formatter type="plain"/>
</test>
-->
<batchtest fork="yes" todir="${build.dir.opt}/testResults">
<fileset dir="${build.dir.opt}/${tmp.workdir}/test">
<include name="localtest/Test*.class"/>
<include name="localtest/feedHits/Test*.class"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- =================================================================== -->
<!-- Prepares the javadoc snapshot; dbg/opt-independent... -->
<!-- =================================================================== -->
<target name="jar.javadoc.testuptodate">
<!-- Claim that the JAR target is up-to-date if its source files/JARs are. -->
<uptodate property="jar.javadoc.uptodate"
targetfile="${javadoc.dir}/index.html">
<srcfiles dir="${jsrc.base.dir}"/>
</uptodate>
</target>
<!--Build javadoc, identically for debug and optimised; rebuild only if source changes so as to save time. -->
<target name="jar.javadoc"
depends="jar.javadoc.testuptodate"
description="builds a javadoc JAR"
unless="jar.javadoc.uptodate">
<delete dir="${javadoc.dir}" quiet="true"/>
<mkdir dir="${javadoc.dir}"/>
<javadoc
destdir="${javadoc.dir}"
classpath="${cp.opt.basic}"
access="private"
verbose="false"
windowtitle="statsHouse V${app.version} Javadoc"
overview="${jsrc.base.dir}/javadoc-overview.html"
linksource="true"
>
<fileset dir="${core.src.dir}"/>
<header><![CDATA[
<a href="http://d.hd.org/" target="_top">statsHouse</a> V${app.version}<br />
]]></header>
<footer>statsHouse V${app.version}</footer>
<bottom>Copyright (c) 2023, Damon Hart-Davis and others.</bottom>
</javadoc>
</target>
<!-- =================================================================== -->
<!-- Builds debug and optimised code from scratch, and tests it. -->
<!-- =================================================================== -->
<target name="all"
depends="clean,core.test.opt,core.jar.opt,core.jar.shMainsuperopt"
description="cleans, then does optimised/release build and test">
<echo message="Builds and tests complete."/>
</target>
<!-- depends="clean,core.jar.opt,src.snapshot" -->
<!-- depends="clean,core.jar.opt,core.jar.shMainsuperopt,src.snapshot" -->
<!-- =================================================================== -->
<!-- Cleans up generated intermediate stuff -->
<!-- =================================================================== -->
<target name="clean"
description="cleans up all generated files and cached state">
<echo message="Doing cleanup of all build dirs..."/>
<parallel>
<delete dir="${test.install.cache.dir}" quiet="true"/> <!-- Slowest job first. -->
<delete dir="${build.dir.dbg}" quiet="true"/>
<delete dir="${build.dir.cmn}" quiet="true"/>
<delete dir="${build.dir.opt}" quiet="true"/>
</parallel>
</target>
</project>