summaryrefslogtreecommitdiff
blob: a522e98471cd70a15e02bb6eb9a0350d2a5fc03a (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
<?xml version="1.0" encoding="UTF-8"?>
<project default="dist" basedir="." name="Freenet" >
	<description >
		This file builds Freenet: What is Freenet?

		Freenet is free software which lets you publish and obtain information on the Internet without fear of censorship. To achieve this freedom, the network is entirely decentralized and publishers and consumers of information are anonymous. Without anonymity there can never be true freedom of speech, and without decentralization the network would be vulnerable to attack.

		Possible targets: compile, dist (default), clean
	</description>

	
	<property file="build.properties" ></property>


	
	<property name="src" location="src" ></property>
	<property name="test" location="test" ></property>
	<property name="build" location="build" ></property>
	<property name="build-test" location="build-test" ></property>
	<property name="lib" location="lib" ></property>
	<property name="freenet-ext.location" location="${lib}/freenet-ext.jar" ></property>
	<property name="javadoc" location="javadoc" ></property>
	<property name="minExtVersion" value="-1" ></property>
	<property name="recommendedExtVersion" value="-1" ></property>
	<property name="GWT.generatedjs" value="${src}/freenet/clients/http/staticfiles/freenetjs" ></property>
	<property name="GWT.lib" value="generator/js/lib" ></property>
	<property name="GWT.lib.dev" value="${GWT.lib}/gwt-dev.jar" ></property>
	<property name="GWT.lib.user" value="${GWT.lib}/gwt-user.jar" ></property>
	<property name="version.src" value="freenet/node/Version.java" ></property>
	<property name="version.build" value="freenet/node/Version.class" ></property>
	<property name="junit.location" value="/usr/share/java/junit.jar" ></property>
	<available property="junit.present" file="${junit.location}" ></available>

	<path id="lib.path" >
		<pathelement location="${freenet-ext.location}" ></pathelement>
		<pathelement location="gnu-crypto.jar" ></pathelement>
		<pathelement location="javax-security.jar" ></pathelement>
		<pathelement location="javax-crypto.jar" ></pathelement>
	</path>

	<assertions >
		<enable ></enable>
	</assertions>

	<exec failifexecutionfails="false" executable="git" errorProperty="git.errror" resultproperty="git.result" outputproperty="git.describe" >
		<arg value="describe" ></arg>
		<arg value="--always" ></arg>
		<arg value="--abbrev=4" ></arg>
	</exec>
	<condition property="git.revision" value="${git.describe}" else="@unknown@" >
		<and >
			<equals arg1="${git.result}" arg2="0" ></equals>
			<isset property="git.describe" ></isset>
		</and>
	</condition>
	

	<target name="mkdir" >
		<mkdir dir="${build}" ></mkdir>
		<mkdir dir="${build-test}" ></mkdir>
		<mkdir dir="${lib}" ></mkdir>
	</target>

	<target depends="mkdir" name="env" description="Learn about the environment" >
		<available property="freenet-ext.present" file="${lib}/freenet-ext.jar" ></available>
		
		<available property="generatedjs.present" type="dir" file="${GWT.generatedjs}" ></available>
		<echo level="verbose" >Javascript generation present:${generatedjs.present}</echo>
		<available property="GWT.lib.dev.present" file="${GWT.lib.dev}" ></available>
		<echo level="verbose" >gwt-dev-linux.jar present:${GWT.lib.dev.present}</echo>
		<available property="GWT.lib.user.present" file="${GWT.lib.user}" ></available>
		<echo level="verbose" >gwt-user.jar present:${GWT.lib.user.present}</echo>
	</target>
	
	<target depends="env" unless="GWT.lib.dev.present" name="get-GWT-lib-dev" >
		<mkdir dir="${GWT.lib}" ></mkdir>
		<get dest="${GWT.lib}/gwt-dev.jar" src="http://localhost/gwt-dev.jar" verbose="true" usetimestamp="true" ></get>
		<property name="GWT.lib.dev.present" value="true" ></property>
	</target>
	
	<target depends="env" unless="GWT.lib.user.present" name="get-GWT-lib-user" >
		<mkdir dir="${GWT.lib}" ></mkdir>
		<get dest="${GWT.lib}/gwt-user.jar" src="http://localhost/gwt-user.jar" verbose="true" usetimestamp="true" ></get>
		<property name="GWT.lib.user.present" value="true" ></property>
	</target>
	
	<target unless="generatedjs.present" name="get-GWT-libs" >
	    <antcall target="get-GWT-lib-dev" ></antcall>
	    <antcall target="get-GWT-lib-user" ></antcall>
	</target>
	
	<target depends="env,get-GWT-libs" unless="generatedjs.present" name="generate-js" >
		<ant antfile="build.xml" dir="generator/js" ></ant>
	</target>

	<target depends="env" unless="freenet-ext.present" name="get-extjar" description="Download some external libraries which Freenet relies on" >
		<mkdir dir="${lib}" ></mkdir>
		<get dest="${freenet-ext.location}" src="http://checksums.freenetproject.org/cc/freenet-ext.jar" verbose="true" usetimestamp="true" ></get>
		<property name="freenet-ext.present" value="true" ></property>
	</target>

	<condition property="do.junit" value="true" >
		<and >
			<isfalse value="${skip_tests}" ></isfalse>
			<isset property="junit.present" ></isset>
		</and>
	</condition>
	

	<target depends="mkdir" name="compile" >
		
		<tstamp ></tstamp>

		
		<copy tofile="${build}/${version.src}" overwrite="true" file="${src}/${version.src}" ></copy>
		<delete quiet="true" file="${build}/${version.build}" ></delete>
		<replace file="${build}/${version.src}" >
			<replacefilter token="@custom@" value="${git.revision}" ></replacefilter>
		</replace>
		<echo message="Updated build version to ${git.revision} in ${build}/${version.src}" ></echo>

		
		<javac target="1.5" destdir="${build}" source="1.5" debug="on" srcdir="${src}" optimize="on" classpath="${gentoo.classpath}" >
<!--			<compilerarg value="-Xlint" ></compilerarg> -->
			
			<sourcepath >
				<pathelement path="${build}" ></pathelement>
			</sourcepath>
			<classpath >
				<path refid="lib.path" ></path>
			</classpath>
			
			<include name="freenet/**/*.java" ></include>
			<include name="net/i2p/util/*.java" ></include>
			<include name="org/**/*.java" ></include>
			<exclude name="**/package-info.java" ></exclude>
			<exclude name="${version.src}" ></exclude>
		</javac>

		
		<javac target="1.5" destdir="${build}" source="1.5" debug="on" srcdir="${build}" optimize="on" classpath="${gentoo.classpath}" >
			<classpath >
				<path refid="lib.path" ></path>
			</classpath>
			<include name="${version.src}" ></include>
		</javac>

		
		<copy todir="${build}/freenet/clients/http/staticfiles" >
			<fileset dir="${src}/freenet/clients/http/staticfiles" ></fileset>
		</copy>
		
		<copy todir="${build}/freenet/l10n" >
			<fileset dir="${src}/freenet/l10n" >
				<include name="freenet.l10n.*.properties" ></include>
				<include name="freenet.l10n.*.tab" ></include>
			</fileset>
		</copy>

	</target>


	

	<target depends="compile,unit" name="dist" description="generate the distribution" >
		
		<jar basedir="${build}" jarfile="${lib}/freenet-cvs-snapshot.jar" >
			<manifest >
				<attribute name="Main-Class" value="freenet/node/Node" ></attribute>
				<attribute name="Built-By" value="${user.name}" ></attribute>
				<attribute name="Required-Ext-Version" value="${minExtVersion}" ></attribute>
				<attribute name="Recommended-Ext-Version" value="${recommendedExtVersion}" ></attribute>
				<attribute name="Class-Path" value="freenet-ext.jar" ></attribute>
				<section name="common" >
					<attribute name="Specification-Title" value="Freenet" ></attribute>
					<attribute name="Specification-Version" value="0.7.5" ></attribute>
					<attribute name="Specification-Vendor" value="freenetproject.org" ></attribute>
					<attribute name="Implementation-Title" value="Freenet" ></attribute>
					<attribute name="Implementation-Version" value="0.7.5 ${TODAY} ${git.revision}" ></attribute>
					<attribute name="Implementation-Vendor" value="Freenetproject.org" ></attribute>
				</section>
			</manifest>
			<exclude name="${version.src}" ></exclude>
		</jar>
	</target>

	

	<target depends="compile" name="unit-build" if="do.junit" >
		<delete dir="${build-test}" ></delete>
		<mkdir dir="${build-test}" ></mkdir>

		<javac target="1.5" destdir="${build-test}" source="1.5" debug="on" srcdir="${test}" optimize="on" classpath="${gentoo.classpath}" >
			<classpath >
				<path refid="lib.path" ></path>
				<pathelement path="${build}" ></pathelement>
				<pathelement location="${junit.location}" ></pathelement>
			</classpath>
			<compilerarg value="-Xlint" ></compilerarg>
			<include name="**/*.java" ></include>
			<exclude name="*.java" ></exclude>
		</javac>
		<copy todir="${build-test}/freenet/client/filter/png" >
			<fileset dir="${test}/freenet/client/filter/png" ></fileset>
		</copy>
		<copy todir="${build-test}/freenet/client/filter/bmp" >
			<fileset dir="${test}/freenet/client/filter/bmp" ></fileset>
		</copy>
	</target>

	<target depends="unit-build" name="unit" if="do.junit" >
		<junit fork="yes" haltonfailure="yes" printsummary="yes" >
			<classpath >
				<path refid="lib.path" ></path>
				<pathelement path="${build}" ></pathelement>
				<pathelement path="${build-test}" ></pathelement>
				<pathelement location="${junit.location}" ></pathelement>
			</classpath>

			<formatter usefile="false" type="plain" ></formatter>

			<batchtest fork="yes" >
				<fileset dir="${build-test}" >
					<include name="**/*Test.class" ></include>
				</fileset>
			</batchtest>
			<sysproperty value="${benchmark}" key="benchmark" ></sysproperty>
			<sysproperty value="${extensiveTesting}" key="extensiveTesting" ></sysproperty>
			
			<assertions >
				<enable ></enable>
			</assertions>
		</junit>
	</target>

	

	<target name="clean" description="Delete class files and docs dir." >
		<delete dir="${build}" ></delete>
		<delete dir="${build-test}" ></delete>
	</target>
	<target name="distclean" description="Delete class files, lib dir and docs dir." >
		<delete dir="${build}" ></delete>
		<delete dir="${build-test}" ></delete>
		<delete dir="${lib}" ></delete>
		<delete dir="${javadoc}" ></delete>
		<ant antfile="build.xml" target="deleteGenerated" dir="generator/js" ></ant>
		
	</target>


	<target name="javadoc" >
		<javadoc sourcepath="${src}" use="true" destdir="${javadoc}" >
			<fileset dir="${src}" includes="**/*.java" ></fileset>
			<classpath >
				<pathelement location="${freenet-ext.location}" ></pathelement>
			</classpath>
			<link href="http://java.sun.com/j2se/1.5.0/docs/api" ></link>
		</javadoc>
	</target>
</project>