summaryrefslogtreecommitdiff
path: root/net-p2p/freenet/files/build-clean.xml
blob: 89698df2675fe500a541d1f0e8adff305f3272ad (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="freenet" default="package" basedir=".">
	<description>
Freenet is free software that lets you publish and retrieve information without
fear of censorship. To achieve this, the network is entirely decentralized, and
all actions are anonymous. Without anonymity, there can never be true freedom
of speech, and without decentralization the network would be vulnerable to attack.

This file is to build Freenet entirely from source. The builder is responsible
for satisfying all library dependencies, e.g. via override.properties. Package
maintainers may prefer to use this instead of build.xml.
	</description>

	<!-- =================================================================== -->
	<!-- Global properties                                                   -->
	<!-- =================================================================== -->

	<!-- user overrides (properties are immutable, so set overrides first) -->
	<property file="override.properties"/>
	<property file="build.properties"/>
	<property file="dependencies.properties"/>

	<property name="version.src" value="freenet/node/Version.java" />
	<property name="version.make" value="freenet/node/Version.class" />

	<path id="lib.path">
		<fileset dir="${lib.contrib.dir}" includes="${lib.contrib.jars}"/>
		<fileset dir="${lib.dir}" includes="${lib.jars}"/>
		<fileset dir="/usr/share/java" includes="${lib.jars}" erroronmissingdir="false"/>
	</path>
	<path id="libtest.path">
		<path refid="lib.path"/>
		<fileset dir="${lib.dir}" includes="${libtest.jars}"/>
		<fileset dir="/usr/share/java" includes="${libtest.jars}" erroronmissingdir="false"/>
		<pathelement path="${main.make}"/>
		<pathelement path="${test.make}"/>
	</path>

	<property name="gjs.dst" value="${main.src}/freenet/clients/http/staticfiles/freenetjs"/>
	<property name="gjs.dir" value="generator/js"/>
	<path id="gjs.lib.path">
		<fileset dir="${gjs.dir}" includes="lib/*.jar"/>
		<pathelement location="${gjs.dir}/war/WEB-INF/classes"/>
		<fileset dir="${lib.dir}" includes="${gjs.lib.jars}"/>
	</path>

	<path id="pmd.classpath">
		<fileset dir="${pmd.dir}" erroronmissingdir="false" includes="lib/*.jar"/>
	</path>

	<property environment="env"/>
	<property name="keystore" value="${env.jarsignerStoreLocation}"/>
	<property name="keystore_alias" value="${env.jarsignerAlias}"/>
	<property name="keystore_pass" value="${env.jarsignerStorePassword}"/>
	<property name="key_pass" value="${env.jarsignerCodeSigningKeyPassword}"/>

	<property name="jar.dst" value="${main.dst}/freenet.jar"/>

	<assertions><enable/></assertions>

	<!-- set version string based on git-describe -->
	<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>

	<!-- =================================================================== -->
	<!-- Miscellaneous                                                       -->
	<!-- =================================================================== -->

	<target name="dist" depends="clean-all, all" description="clean-build everything"/>

	<target name="sign" description="Sign the distribution" depends="package">
		<echo message="Signing the distribution"/>
		<signjar jar="${jar.dst}" strict="false" tsaurl="http://timestamp.comodoca.com/rfc3161" alias="${keystore_alias}" keystore="${keystore}" storepass="${keystore_pass}" keypass="${key_pass}" sigalg="SHA256withRSA" digestalg="SHA-256"/>
		<!-- TODO: Should have strict="true", but it was introduced in Java 7, which we cannot yet require. -->
		<verifyjar jar="${jar.dst}" alias="${keystore_alias}" keystore="${keystore}" storepass="${keystore_pass}" keypass="${key_pass}"/>
	</target>

	<target name="all" depends="package, doc, findbugs, pmd, cpd" description="build everything, incl. docs, GWT js"/>

	<target name="clean-all" depends="clean, clean-doc, clean-gjs" description="clean all build products, incl. docs, GWT js"/>

	<target name="help" description="display help on parameters">
		<echo message="For main build targets, see `ant -p`"/>
		<echo message=""/>
		<echo message="Test parameters (-Dtest.PARAM=true)"/>
		<echo message="  skip        Skip all tests"/>
		<echo message="  verbose     Report additional information"/>
		<echo message="  benchmark   Run benchmark tests"/>
		<echo message="  extensive   Run extensive tests"/>
		<echo message=""/>
		<echo message="Misc parameters (-DPARAM=VALUE)"/>
		<echo message="  javac.args  Command line arguments to pass to javac"/>
		<echo message=""/>
	</target>

	<target name="findbugs" depends="package" unless="${findbugs.skip}">
		<antcall target="libdep-findbugs"/>
		<echo message="Running Findbugs"/>
		<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs.path}"/>

		<findbugs home="${findbugs.dir}"
		output="xml"
		outputFile="${test.dst}/findbugs.xml"
		warningsProperty="findbugs.module.warnings"
		failOnError="true"
		jvmargs="-Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=128m" >
		<auxClasspath refid="lib.path" />
		<sourcePath path="${main.src}" />
		<class location="${jar.dst}" />
		</findbugs>
	</target>

	<target name="pmd" depends="package" unless="${pmd.skip}">
		<antcall target="libdep-pmd"/>
		<echo message="Running PMD"/>
		<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
		<pmd rulesetfiles="rulesets/java/design.xml" encoding="utf-8">
			<formatter type="xml" toFile="${test.dst}/pmd.xml"/>
			<fileset dir="${main.src}">
				<include name="**/*.java"/>
			</fileset>
		</pmd>
	</target>

	<target name="cpd" depends="package" unless="${cpd.skip}">
		<antcall target="libdep-cpd"/>
		<echo message="Running CPD"/>
		<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.classpath"/>
		<cpd minimumTokenCount="100" format="xml" outputFile="${test.dst}/cpd.xml">
			<fileset dir="${main.src}">
				<include name="**/*.java"/>
			</fileset>
		</cpd>	
	</target>

	<target name="debug">
		<echoproperties/>
	</target>

	<!-- =================================================================== -->
	<!-- Library dependencies                                                -->
	<!-- =================================================================== -->

	<!--
	currently we only check for the most common cases of missing libraries.
	this does result in less clear error messages for more obscure setups, e.g.
	if you have debian's gwt-dev.jar but not commons-collections3.jar. however,
	to cover all scenarios would be a pain.
	-->

	<target name="env">
		<available property="lib.contrib.present" classname="freenet.node.ExtVersion" classpathref="lib.path"/>
		<available property="lib.bouncycastle.present" classname="org.bouncycastle.crypto.signers.HMacDSAKCalculator" classpathref="lib.path"/>
		<available property="lib.junit.present" classname="org.junit.runners.JUnit4" classpathref="libtest.path"/>
		<available property="lib.hamcrest.present" classname="org.hamcrest.SelfDescribing" classpathref="libtest.path"/>
		<available property="lib.findbugs.present" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="${findbugs.path}"/>
		<available property="lib.pmd.present" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
		<available property="lib.cpd.present" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.classpath"/>
		<available property="gjs.lib.gwt-user.present" classname="com.google.gwt.user.client.Window" classpathref="gjs.lib.path"/>
		<available property="gjs.lib.gwt-dev.present" classname="com.google.gwt.dev.About" classpathref="gjs.lib.path"/>
		<condition property="gjs.lib.gwt.present">
			<and>
				<isset property="gjs.lib.gwt-user.present"/>
				<isset property="gjs.lib.gwt-dev.present"/>
			</and>
		</condition>
	</target>

	<target name="libdep-ext" depends="env" unless="lib.contrib.present">
		<fail message="freenet-ext not available"/>
	</target>

	<target name="libdep-bc" depends="env" unless="lib.bouncycastle.present">
		<fail message="Bouncycastle not available (or not recent enough); try https://www.bouncycastle.org/download/${bc.jar}"/>
	</target>

	<target name="libdep-junit" depends="env" unless="lib.junit.present">
		<fail message="JUnit4 not available"/>
	</target>

	<target name="libdep-hamcrest" depends="env" unless="lib.hamcrest.present">
		<fail message="Hamcrest-core not available"/>
	</target>

	<target name="libdep-findbugs" depends="env" unless="lib.findbugs.present">
		<fail message="findbugs not available"/>
	</target>

	<target name="libdep-pmd" depends="env" unless="lib.pmd.present">
		<fail message="PMD not available"/>
	</target>

	<target name="libdep-cpd" depends="env" unless="lib.cpd.present">
		<fail message="CPD not available"/>
	</target>

	<target name="libdep-gwt-user" depends="env" unless="gjs.lib.gwt-user.present">
		<fail message="GWT-user not present"/>
	</target>

	<target name="libdep-gwt-dev" depends="env" unless="gjs.lib.gwt-dev.present">
		<fail message="GWT-dev not present"/>
	</target>

	<!-- =================================================================== -->
	<!-- Standard build                                                      -->
	<!-- =================================================================== -->

	<target name="init">
		<mkdir dir="${main.make}"/>
		<mkdir dir="${main.dst}"/>
		<mkdir dir="${test.make}"/>
		<mkdir dir="${test.dst}"/>
	</target>

	<target name="dep" depends="ensure-ext, ensure-bc, ensure-gjs"/>

	<target name="check-version-file">
		<uptodate property="version.uptodate"
		  targetfile="${main.make}/${version.src}"
		  srcfile="${main.src}/${version.src}"/>
	</target>

	<target name="build-version-file" depends="check-version-file" unless="version.uptodate">
		<!-- Create the Version file with patched revision number in ${main.make} -->
		<copy file="${main.src}/${version.src}" tofile="${main.make}/${version.src}" overwrite="true" />
		<delete file="${main.make}/${version.make}" quiet="true" />
		<replace file="${main.make}/${version.src}">
			<replacefilter token="@custom@" value="${git.revision}"/>
		</replace>
		<echo message="Updated build version to ${git.revision} in ${main.make}/${version.src}"/>
	</target>

	<target name="build" depends="init, dep, build-version-file">
		<!-- Create the time stamp -->
		<tstamp/>
		<!-- Create the build directory structure used by compile -->
		<javac srcdir="${main.src}" destdir="${main.make}" debug="on" source="1.7" target="1.7" includeAntRuntime="false" encoding="UTF-8">
			<compilerarg line="${javac.args}"/>
			<classpath refid="lib.path"/>
			<!-- tell javac to find Version.java in ${main.make}, not ${main.src} -->
			<sourcepath><pathelement path="${main.make}"/></sourcepath>
			<!-- following a very temporary list of files to be build -->
			<include name="**/*.java"/>
			<exclude name="**/package-info.java"/>
			<exclude name="${version.src}"/>
		</javac>

		<!-- Force compile of Version.java in case compile of ${main.src} didn't trigger it -->
		<javac srcdir="${main.make}" destdir="${main.make}" debug="on" source="1.7" target="1.7" includeAntRuntime="false" encoding="UTF-8">
			<compilerarg line="${javac.args}"/>
			<classpath refid="lib.path"/>
			<include name="${version.src}"/>
		</javac>

		<!-- Copy web interface static files to the build dir -->
		<copy todir="${main.make}/freenet/clients/http/staticfiles">
			<fileset dir="${main.src}/freenet/clients/http/staticfiles"/>
		</copy>
		<!-- Copy translation files to the build dir -->
		<copy todir="${main.make}/freenet/l10n">
			<fileset dir="${main.src}/freenet/l10n">
				<include name="freenet.l10n.*.properties"/>
				<include name="iso-*.tab"/>
			</fileset>
		</copy>
		<!-- Copy the dependencies.properties file -->
		<copy todir="${main.make}" file="dependencies.properties"/>
	</target>

	<target name="package-only" depends="build">
		<property name="lib.contrib.loc" location="${lib.contrib.dir}" />
		<property name="lib.loc" location="${lib.dir}" />
		<pathconvert property="lib.jars.package" refid="lib.path" pathsep=" ">
			<map from="${lib.contrib.loc}/" to=""/>
			<map from="${lib.loc}/" to=""/>
		</pathconvert>
		<jar jarfile="${jar.dst}" basedir="${main.make}">
			<manifest>
				<attribute name="Permissions" value="all-permissions"/>
				<attribute name="Application-Name" value="Freenet REference Daemon"/>

				<attribute name="Required-Ext-Version" value="29"/>
				<attribute name="Recommended-Ext-Version" value="29"/>
				<section name="common">
					<attribute name="Specification-Title" value="Freenet"/>
					<attribute name="Specification-Version" value="0.7.5"/>
					<attribute name="Specification-Vendor" value="freenetproject.org"/>
					<attribute name="Implementation-Title" value="Freenet"/>
					<attribute name="Implementation-Version" value="0.7.5 ${git.revision}"/>
					<attribute name="Implementation-Vendor" value="freenetproject.org"/>
				</section>
			</manifest>
			<exclude name="${version.src}"/>
		</jar>
	</target>

	<target name="package" depends="unit, package-only" description="build standard binary packages (Freenet daemon)"/>

	<target name="unit-build" depends="build" unless="${test.skip}">
		<antcall target="libdep-junit"/>
		<antcall target="libdep-hamcrest"/>
		<javac srcdir="${test.src}" destdir="${test.make}" debug="on" source="1.7" target="1.7" includeAntRuntime="false" encoding="UTF-8">
			<compilerarg line="${javac.args}"/>
			<classpath refid="libtest.path"/>
			<include name="**/*.java"/>
			<exclude name="*.java"/>
		</javac>
		<copy todir="${test.make}/freenet/client/filter/png" overwrite="true">
			<fileset dir="${test.src}/freenet/client/filter/png"/>
		</copy>
		<copy todir="${test.make}/freenet/client/filter/bmp" overwrite="true">
			<fileset dir="${test.src}/freenet/client/filter/bmp"/>
		</copy>
		<copy todir="${test.make}/freenet/client/filter/mp3" overwrite="true">
			<fileset dir="${test.src}/freenet/client/filter/mp3"/>
		</copy>
		<copy todir="${test.make}/freenet/client/filter/gif" overwrite="true">
			<fileset dir="${test.src}/freenet/client/filter/gif"/>
		</copy>
		<copy todir="${test.make}/freenet/crypt/ciphers/rijndael-gladman-test-data" overwrite="true">
			<fileset dir="${test.src}/freenet/crypt/ciphers/rijndael-gladman-test-data"/>
		</copy>
		<copy todir="${test.make}/freenet/l10n" overwrite="true">
			<fileset dir="${test.src}/freenet/l10n" includes="*.properties"/>
		</copy>
	</target>

	<target name="unit" depends="unit-build" unless="${test.skip}">
		<junit printsummary="yes" haltonfailure="${test.haltonfailure}" logfailedtests="yes" showoutput="yes" filtertrace="no" fork="on" forkmode="perTest" maxmemory="256m" dir="${test.dst}">
			<classpath refid="libtest.path"/>
			<formatter type="plain" usefile="false"/>
			<formatter type="xml" if="${test.xml_output}"/>
			<formatter classname="org.apache.tools.ant.taskdefs.optional.junit.TearDownOnVmCrash" usefile="false"/>
			<test if="test.class" name="${test.class}" todir="${test.dst}"/>
			<batchtest unless="test.class" fork="yes" todir="${test.dst}">
				<fileset dir="${test.make}" includes="**/*Test.class"/>
			</batchtest>
			<sysproperty key="test.verbose" value="${test.verbose}"/>
			<sysproperty key="test.benchmark" value="${test.benchmark}"/>
			<sysproperty key="test.extensive" value="${test.extensive}"/>
			<!-- TODO source needs to be edited too; the old variables were "benchmark" and "extensiveTesting" -->
			<assertions><enable/></assertions>
		</junit>
	</target>

	<target name="clean" description="clean standard build products">
		<delete dir="${main.make}"/>
		<delete dir="${main.dst}"/>
		<delete dir="${test.make}"/>
		<delete dir="${test.dst}"/>
	</target>

	<!-- =================================================================== -->
	<!-- Dependencies (contrib, ie. freenet-ext.jar)                         -->
	<!-- =================================================================== -->

	<target name="ensure-ext" depends="libdep-ext">
		<!-- clean build does nothing, since this is external library. -->
	</target>

	<target name="ensure-bc" depends="libdep-bc">
		<!-- clean build does nothing, since this is external library. -->
	</target>

	<!-- =================================================================== -->
	<!-- Generate GWT code                                                   -->
	<!-- =================================================================== -->

	<target name="env-gjs">
		<available property="gjs.present" file="${gjs.dst}" type="dir"/>
	</target>

	<target name="ensure-gjs" depends="env-gjs" unless="gjs.present">
		<antcall target="build-gjs"/>
	</target>

	<target name="build-gjs" depends="libdep-gwt-user, libdep-gwt-dev">
		<ant antfile="build.xml" dir="${gjs.dir}">
			<reference refid="gjs.lib.path" torefid="project.class.path"/>
		</ant>
	</target>

	<target name="clean-gjs">
		<ant antfile="build.xml" dir="${gjs.dir}" target="deleteGenerated"/>
	</target>

	<!-- =================================================================== -->
	<!-- Documentation                                                       -->
	<!-- =================================================================== -->

	<target name="init-doc" unless="${doc.skip}">
		<mkdir dir="${doc.api}"/>
	</target>

	<target name="javadoc" depends="init-doc, dep" unless="${doc.skip}">
		<javadoc classpathref="lib.path" sourcepath="${main.src}" destdir="${doc.api}" use="true">
			<link href="http://docs.oracle.com/javase/6/docs/api/"/>
		</javadoc>
	</target>

	<target name="doc" depends="javadoc" description="build documentation">
		<!-- currently freenet has no other documentation apart from javadocs -->
	</target>

	<target name="clean-doc" unless="${doc.skip}">
		<delete dir="${doc.api}"/>
	</target>

</project>