-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.xml
434 lines (384 loc) · 19.2 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
<?xml version="1.0"?>
<!-- ant build file for WoT -->
<project name="WoT" default="dist" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<!-- ======================================================================================= -->
<!-- Configuration -->
<!-- ======================================================================================= -->
<!-- You can use this file to override the below properties. -->
<property file="override.properties"/>
<!-- Dependencies. These are the most important to configure! -->
<!-- -->
<!-- Freenet build01481 compiled with "./gradlew jar copyRuntimeLibs" will copy the -->
<!-- freenet.jar and its dependencies to this directory: -->
<property name="freenet.lib.new.location" location="../fred/build/output/"/>
<!-- Older Freenet builds will use these places for the JARs, some of which have to be -->
<!-- downloaded manually: -->
<property name="freenet.lib.old.location.1" location="../fred/lib/bcprov.jar"/>
<property name="freenet.lib.old.location.2" location="../fred/lib/jna-platform.jar"/>
<property name="freenet.lib.old.location.3" location="../fred/lib/jna.jar"/>
<property name="freenet.lib.old.location.4" location="../fred/lib/freenet/freenet-ext.jar"/>
<property name="freenet.lib.old.location.5" location="../fred/dist/freenet.jar"/>
<!-- Unit test dependencies -->
<property name="junit.location" value="/usr/share/java/junit4.jar"/>
<property name="hamcrest.location" value="/usr/share/java/hamcrest-core.jar"/>
<!-- Optional, only needed if using "ant -Dtest.coverage=true" -->
<property name="cobertura.location" value="/usr/share/java/cobertura.jar"/>
<!-- Minimum Java version which fred officially requires
= Maximum version which WoT's code can use features of. -->
<property name="source-version" value="7"/>
<property name="target-version" value="7"/>
<!-- To allow you to restart your debug node after recompiling without manually reloading
the WoT plugin you can specifiy this property to point to the node's WebOfTrust.jar.
The Ant builder will delete it automatically as part of the "clean" target. -->
<property name="debug-node-wot-plugin.location" location="../fred/plugins/WebOfTrust.jar"/>
<!-- ======================================================================================= -->
<!-- Configuration which you should probably leave as is! -->
<!-- ======================================================================================= -->
<!-- Git submodule directory of the db4o source code. Will be compiled automatically! -->
<property name="db4o-submodule.location" location="db4o-7.4"/>
<!-- JAR which the Ant builder of db4o produces. -->
<property name="db4o.location" location="${db4o-submodule.location}/db4o.jar"/>
<property name="svn.revision" value="@custom@"/>
<property name="build" location="build/"/>
<property name="build-test" location="build-test/"/>
<property name="build-test-jar" location="${build-test}/WebOfTrust-with-unit-tests.jar"/>
<property name="build-test-coverage" location="test-coverage/"/>
<property name="dist" location="dist/"/>
<property name="src" location="src/"/>
<property name="javadoc" location="javadoc/"/>
<property name="version.src" value="plugins/WebOfTrust/Version.java" />
<property name="version.build" value="plugins/WebOfTrust/Version.class" />
<available file="src/plugins/WebOfTrust/Version.java" property="version.present"/>
<available file="${junit.location}" property="junit.present"/>
<available file="${hamcrest.location}" property="hamcrest.present"/>
<available file="${cobertura.location}" property="cobertura.present"/>
<property name="test.coverage" unless:set="${test.coverage}" if:true="${cobertura.present}" value="true"/>
<!-- Libraries whose classes are to be bundled in our own JAR. -->
<path id="submodules.path">
<pathelement location="${db4o.location}"/>
</path>
<!-- Libraries which we get from fred. -->
<path id="lib.path">
<!-- Use filesets instead of <pathelement> to:
- allow using wildcards when including freenet.lib.new.location so we don't need to
synchronize the list of JARs which fred needs with what this build file includes.
- for the old JAR locations ensure the print-libs task won't print files which don't
exist as that is what he wildcard usage dictates for thew new location already. -->
<fileset dir="${freenet.lib.new.location}" erroronmissingdir="no" casesensitive="no">
<include name="**/*.jar"/>
</fileset>
<fileset file="${freenet.lib.old.location.1}" erroronmissingdir="no"/>
<fileset file="${freenet.lib.old.location.2}" erroronmissingdir="no"/>
<fileset file="${freenet.lib.old.location.3}" erroronmissingdir="no"/>
<fileset file="${freenet.lib.old.location.4}" erroronmissingdir="no"/>
<fileset file="${freenet.lib.old.location.5}" erroronmissingdir="no"/>
</path>
<path id="cobertura.path">
<pathelement location="${cobertura.location}"/>
</path>
<!-- For print-libs task: All runtime dependencies of WoT plus the build-time dependencies.
Uses <fileset> instead of <pathelement> so it only contains only those which exist as that
is what lib.path does already. -->
<path id="lib.external.all.path">
<path refid="lib.path"/>
<fileset file="${junit.location}" />
<fileset file="${hamcrest.location}"/>
<fileset file="${cobertura.location}"/>
</path>
<!-- For junit - we need to specify some command line arguments on Java >= 9 -->
<condition property="java.atleast9">
<javaversion atleast="9"/>
</condition>
<presetdef name="javac">
<!--
includeantruntime is a workaround for an ant 1.8 misfeature. TODO: Remove when ant fixes this.
If we don't set this to false, we will get "warning: 'includeantruntime' was not set, defaulting to
build.sysclasspath=last; set to false for repeatable builds"
(includeAntRuntime = "Whether to include the Ant run-time libraries in the classpath; defaults to yes,
unless build.sysclasspath is set. It is usually best to set this to false so the script's behavior
is not sensitive to the environment in which it is run."
Source: https://ant.apache.org/manual/Tasks/javac.html)
-->
<javac includeantruntime="false" encoding="UTF-8"/>
</presetdef>
<exec executable="git"
failifexecutionfails="false"
errorProperty="git.errror"
outputproperty="git.describe"
resultproperty="git.result">
<arg value="describe" />
<arg value="--always" />
<arg value="--abbrev=4" />
<arg value="--dirty" />
</exec>
<condition property="git.revision" value="${git.describe}" else="@unknown@">
<and>
<equals arg1="${git.result}" arg2="0" />
<isset property="git.describe" />
</and>
</condition>
<target name="get-submodules" description="Downloads the git submodules required by WoT">
<echo>Downloading db4o git submodule if it doesn't exist already...</echo>
<exec executable="git">
<arg line="submodule update --init"/>
</exec>
</target>
<target name="db4o" depends="get-submodules" description="Compiles the database submodule">
<echo>Compiling db4o submodule...</echo>
<ant dir="${db4o-submodule.location}" inheritAll="false" useNativeBasedir="true">
<property name="javac.source.version" value="${source-version}"/>
<property name="javac.target.version" value="${target-version}"/>
</ant>
</target>
<target name="clean-db4o" depends="get-submodules" description="Cleans the database submodule">
<echo>Cleaning db4o submodule...</echo>
<ant dir="${db4o-submodule.location}" target="clean" inheritAll="false"
useNativeBasedir="true"/>
</target>
<target name="print-libs">
<echo>External dependencies on classpath follow, but ONLY those which did exist.</echo>
<echo>(This cannot tell which JARs are missing because that would require ant-contrib</echo>
<echo>and I don't want to require Freenet release managers to install it. Sorry.)</echo>
<echo></echo>
<echo>If compiling fails due to missing classes please:</echo>
<echo>- ensure fred was built with "./gradlew jar copyRuntimeLibs" to make it copy</echo>
<echo> its dependencies' JARs to "build/output/".</echo>
<echo>- compare the found JARs against the configuration at top of build.xml to find</echo>
<echo> out which JARs are missing.</echo>
<echo></echo>
<pathconvert refid="lib.external.all.path" pathsep="${line.separator}" property="all.path.printable"/>
<echo>${all.path.printable}</echo>
</target>
<target name="mkdir">
<mkdir dir="${build}"/>
<mkdir dir="${build-test}"/>
<mkdir dir="${build-test}/classes"/>
<mkdir dir="${build-test-coverage}"/>
<mkdir dir="${dist}"/>
</target>
<!-- ================================================== -->
<target name="compile" depends="print-libs, db4o, mkdir">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the Version file with patched revision number in ${build} -->
<copy file="${src}/${version.src}" tofile="${build}/${version.src}" overwrite="true" />
<delete file="${build}/${version.build}" quiet="true" />
<replace file="${build}/${version.src}">
<replacefilter token="@custom@" value="${git.revision}"/>
</replace>
<echo message="Updated build version to ${git.revision} in ${build}/${version.src}"/>
<!-- Force compile of Version.java in case compile of ${src} didn't trigger it -->
<javac srcdir="${build}" destdir="${build}" debug="on" optimize="on" source="${source-version}" target="${target-version}">
<classpath>
<path refid="submodules.path"/>
<path refid="lib.path"/>
</classpath>
<include name="${version.src}"/>
</javac>
<javac srcdir="src/" destdir="${build}" debug="on" optimize="on" source="${source-version}" target="${target-version}">
<classpath>
<path refid="submodules.path"/>
<path refid="lib.path"/>
</classpath>
<include name="**/*.java"/>
<exclude name="${version.src}"/>
</javac>
<copy todir="${build}">
<fileset dir="src/">
<include name="**/*.l10n" />
</fileset>
</copy>
</target>
<!-- ================================================== -->
<condition property="unit.dependencies">
<and>
<istrue value="${junit.present}"/>
<istrue value="${hamcrest.present}"/>
</and>
</condition>
<target name="junit-compile" depends="compile" if="unit.dependencies">
<javac srcdir="test/" destdir="${build-test}/classes" debug="on" optimize="on"
source="${source-version}" target="${target-version}">
<classpath>
<path refid="submodules.path"/>
<path refid="lib.path"/>
<pathelement path="${build}"/>
<pathelement location="${junit.location}"/>
<pathelement location="${hamcrest.location}"/>
</classpath>
<compilerarg value="-Xlint"/>
<include name="**/*.java"/>
</javac>
<!-- Copy main non-test classes to tests so we can produce a full working WoT JAR -->
<copy todir="${build-test}/classes" overwrite="false">
<fileset dir="${build}/"/>
</copy>
</target>
<target name="junit-inject-cobertura" depends="clean, junit-compile"
if="${test.coverage}" unless="${test.benchmark}">
<fail unless:true="${cobertura.present}" message="${cobertura.location} not found!"/>
<taskdef classpathref="cobertura.path" resource="tasks.properties"/>
<cobertura-instrument datafile="${build-test-coverage}/cobertura.ser">
<auxClasspath>
<path refid="submodules.path"/>
<path refid="lib.path"/>
</auxClasspath>
<fileset dir="${build-test}/classes">
<include name="**/*.class" />
<!-- kaptcha is a third-party library -->
<exclude name="plugins/WebOfTrust/introduction/captcha/kaptcha/**/*"/>
<exclude name="**/*Test*.class"/>
<exclude name="**/*Benchmark*.class"/>
</fileset>
</cobertura-instrument>
</target>
<target name="junit-package" depends="junit-compile, junit-inject-cobertura">
<jar jarfile="${build-test-jar}" duplicate="fail">
<manifest>
<attribute name="Plugin-Main-Class" value="plugins.WebOfTrust.WebOfTrust"/>
</manifest>
<fileset dir="src/" casesensitive="no">
<include name="*.txt"/> <!-- Include the GPL -->
</fileset>
<fileset dir="${build-test}/classes/"/> <!-- Separate directory to exclude the JAR -->
<zipfileset>
<path refid="submodules.path"/>
</zipfileset>
</jar>
</target>
<target name="junit" depends="junit-package" unless="${test.skip}"
description="Runs all unit tests. Options to specify with 'ant -D':
- Set test.coverage=true to analyze test coverage. View by e.g.: firefox test-coverage/html/index.html
- Set test.skip=true to skip. The tests will still be compiled so you can run them from e.g. Eclipse!
- Set test.class=<test class> (e.g. test.class=plugins.WebOfTrust.WoTTest) to run a single test
- Set test.benchmark=true to run benchmarks.
- Set test.unreliable=true to run tests which may fail on slow machines.">
<fail unless="${unit.dependencies}" message="One of the unit test dependencies not found:
${junit.location}
${hamcrest.location}
You can adjust these paths in file 'override.properties', see 'build.xml'.
Use parameter -Dtest.skip=true to compile without running the self-tests.
WARNING: Web of Trust uses lots of comprehensive tests, changing the code without
running them is a very bad idea!"/>
<!-- Regular non-benchmark unit tests. -->
<!-- The 512 MB memory limit was determined by running ~ 10 iterations of the tests as of
git describe == build0019-236-gfaf9fdb with 4GB, 512 MB, 384 MB and 256 MB. The runtime
average wasn't significantly different for any of those so there is no excessive GCing
happening and 512 MB should be enough for now and leave some leeway for new tests.
showoutput was enabled for IdentityFetcherTest so you can watch its progress on stdout
while it is still running instead of only getting it shown after it's finished. -->
<junit printsummary="yes" fork="yes" haltonfailure="yes" unless:true="${test.benchmark}"
maxmemory="512m" showoutput="yes">
<classpath>
<path refid="lib.path"/>
<pathelement location="${build-test-jar}"/>
<pathelement location="${junit.location}"/>
<pathelement location="${hamcrest.location}"/>
<pathelement location="${cobertura.location}" if:true="${test.coverage}"/>
</classpath>
<assertions><enable/></assertions>
<formatter type="plain" usefile="false"/>
<test if="test.class" name="${test.class}"/>
<batchtest unless="test.class">
<zipfileset src="${build-test-jar}">
<include name="**/*Test*.class"/>
<!-- Exclude member classes:
Java will auto-generate switchtable classes for switch() upon enums.
JUnit would then complain that those classes do not contain a public
constructor. -->
<exclude name="**/*$*.class"/>
<exclude name="**/*Benchmark*.class"/>
<exclude name="**/SynchronousDelayedBackgroundJobTest.class"
unless="test.unreliable" />
<exclude name="**/TickerDelayedBackgroundJobTest.class"
unless="test.unreliable" />
<exclude name="com/db4o/**"/>
</zipfileset>
</batchtest>
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${build-test-coverage}/cobertura.ser" if:true="${test.coverage}"/>
<sysproperty key="extensiveTesting" value="${extensiveTesting}" />
<jvmarg if:true="${java.atleast9}" line="--add-opens java.base/java.lang=ALL-UNNAMED"/>
<jvmarg value="-Djava.awt.headless=true"/>
<!-- See IS_UNIT_TEST at class Configuration -->
<jvmarg value="-Dis_WOT_unit_test=true"/>
<!-- Pass the name of the JAR to the tests so they can load it into a fred instance -->
<jvmarg value="-DWOT_test_jar=${build-test-jar}"/>
</junit>
<cobertura-report if:true="${test.coverage}" unless:true="${test.benchmark}"
srcdir="${src}"
datafile="${build-test-coverage}/cobertura.ser"
destdir="${build-test-coverage}/html"
format="html"/>
<!-- Benchmarks. They need assertions disabled so they're a task of their own. -->
<!-- Also, we set showoutput="true" so you get live output as benchmarks take a long time -->
<junit printsummary="yes" showoutput="true" fork="yes" haltonfailure="yes" if:true="${test.benchmark}">
<classpath>
<path refid="lib.path"/>
<pathelement location="${build-test-jar}"/>
<pathelement location="${junit.location}"/>
<pathelement location="${hamcrest.location}"/>
</classpath>
<assertions><disable/></assertions>
<formatter type="plain" usefile="false"/>
<test if="test.class" name="${test.class}"/>
<batchtest unless="test.class">
<zipfileset src="${build-test-jar}">
<include name="**/*Benchmark*.class"/>
<!-- Exclude member classes:
Java will auto-generate switchtable classes for switch() upon enums.
JUnit would then complain that those classes do not contain a public
constructor. -->
<exclude name="**/*$*.class"/>
<exclude name="com/db4o/**"/>
</zipfileset>
</batchtest>
<sysproperty key="extensiveTesting" value="${extensiveTesting}" />
<jvmarg if:true="${java.atleast9}" line="--add-opens java.base/java.lang=ALL-UNNAMED"/>
<jvmarg value="-Djava.awt.headless=true"/>
<!-- See IS_UNIT_TEST at class Configuration -->
<jvmarg value="-Dis_WOT_unit_test=true"/>
<!-- Pass the name of the JAR to the tests so they can load it into a fred instance -->
<jvmarg value="-DWOT_test_jar=${build-test-jar}"/>
</junit>
</target>
<!-- ================================================== -->
<target name="dist" depends="clean,compile,junit"
description="generate the distribution" >
<jar jarfile="${dist}/WebOfTrust.jar" duplicate="fail">
<manifest>
<attribute name="Plugin-Main-Class" value="plugins.WebOfTrust.WebOfTrust"/>
</manifest>
<fileset dir="src/" casesensitive="no">
<include name="*.txt"/> <!-- Include the GPL -->
</fileset>
<fileset dir="${build}/"/>
<zipfileset>
<path refid="submodules.path"/>
</zipfileset>
</jar>
</target>
<!-- ================================================== -->
<target name="javadoc" description="generate javadocs">
<delete dir="${javadoc}"/>
<path id="javadoc.classpath">
<path refid="submodules.path"/>
<path refid="lib.path"/>
</path>
<javadoc classpathref="javadoc.classpath" destdir="${javadoc}" author="true" version="true" use="true" private="true">
<fileset dir="src/" defaultexcludes="yes">
<include name="**/*.java"/>
</fileset>
<link href="http://docs.oracle.com/javase/${source-version}/docs/api/"/>
<link href="http://freenetproject.org/javadocs/"/>
</javadoc>
</target>
<!-- ================================================== -->
<target name="clean" depends="clean-db4o" description="Delete class files and docs dir and the plugin file in plugins/ of your debug node.">
<delete dir="${build}"/>
<delete dir="${build-test}"/>
<delete dir="${build-test-coverage}"/>
<delete dir="${dist}"/>
<delete file="${debug-node-wot-plugin.location}"/>
</target>
</project>