More progress, no idea if we are working yet
[captive-validator.git] / build.xml
1 <?xml version="1.0"?>
2
3 <project default="compile" basedir=".">
4
5   <!-- defaults -->
6   <property name="build.deprecation" value="off" />
7   <property name="build.debug" value="off" />
8
9   <!-- import local build options -->
10   <property file="build.properties" />
11
12   <!-- import current version string -->
13   <property file="VERSION" />
14
15   <!-- the base location to put build targets -->
16   <property name="build.dir" value="build" />
17   <!-- where to put compiled class files -->
18   <property name="build.dest" value="${build.dir}/classes" />
19   <!-- where to put generated jar files -->
20   <property name="build.lib.dest" value="${build.dir}/lib" />
21   <!-- where to put generated javadocs -->
22   <property name="javadoc.dest" value="${build.dir}/doc" />
23   <!-- where to find the java source -->
24   <property name="build.src" value="src" />
25
26   <!-- where to find external jar files -->
27   <property name="lib.dir" value="lib" />
28
29   <!-- where the unit tests reside -->
30   <property name="test.dir" value="test" />
31   <property name="test.reports" value="${test.dir}/reports" />
32
33   <!-- PREPARE targets -->
34
35   <target name="prepare-env">
36     <!-- see if the 'test' directory exists -->
37     <available file="${test.dir}" type="dir" property="test.present" />
38
39     <!-- set the standard classpath -->
40     <path id="project.classpath">
41       <pathelement location="${build.dest}" />
42       <fileset dir="${lib.dir}" includes="*.jar,*.zip" />
43     </path>
44     <property name="project.classpath" refid="project.classpath" />
45
46   </target>
47
48   <target name="prepare-src" depends="prepare-env">
49     <mkdir dir="${build.dest}" />
50     <mkdir dir="${build.lib.dest}" />
51   </target>
52
53   <target name="prepare-test" depends="prepare-src" if="test.present">
54     <mkdir dir="${test.dir}/${build.dest}" />
55     <mkdir dir="${test.reports}" />
56
57     <path id="test.classpath">
58       <pathelement location="${test.dir}/${build.dest}" />
59       <pathelement path="${project.classpath}" />
60       <fileset dir="${test.dir}/${lib.dir}" includes="*jar,*.zip" />
61     </path>
62     <property name="test.classpath" refid="test.classpath" />
63   </target>
64
65   <!-- BUILD targets -->
66
67   <target name="dnsjava">
68
69     <javac srcdir="dnsjava"
70            destdir="${build.dest}"
71            deprecation="${build.deprecation}"
72            debug="${build.debug}"
73            target="1.4"
74            source="1.4"
75            includes="org/xbill/DNS/" />
76     <jar destfile="${build.lib.dest}/dnsjava-unbound.jar"
77          basedir="${build.dest}"
78          includes="org/xbill/DNS/" />
79
80   </target>
81
82   <target name="unbound-proto" depends="prepare-src, dnsjava" >
83     <javac srcdir="${build.src}"
84            destdir="${build.dest}"
85            deprecation="${build.deprecation}"
86            debug="${build.debug}"
87            target="1.4"
88            source="1.4"
89            classpathref="project.classpath"
90            includes="se/rfc/unbound/" />
91   </target>
92   
93   <target name="unbound-proto-jar" depends="unbound-proto">
94     <jar jarfile="${build.lib.dest}/unbound-prototype.jar"
95          basedir="${build.dest}"
96          includes="se/rfc/unbound/" />
97          
98   </target>
99
100
101   <!-- DOC targets -->
102
103   <target name="javadoc-unbound-proto" depends="prepare-src">
104     <mkdir dir="${javadoc.dest}" />
105     <javadoc packagenames="se.rfc.unbound.*"
106              sourcepath="${build.src}"
107              overview=""
108              classpath="${project.classpath}"
109              destdir="${javadoc.dest}"
110              verbose="false"
111              version="true"
112              author="true"
113              use="true"
114              windowtitle="Unbound Prototype API Documentation">
115     </javadoc>
116   </target>
117
118   <!-- TEST targets -->
119   <target name="build-tests" depends="prepare-test, unbound-proto"
120           if="test.present">
121     <javac srcdir="${test.dir}/${build.src}"
122            destdir="${test.dir}/${build.dest}"
123            deprecation="${build.deprecation}"
124            debug="${build.debug}"
125            target="1.4"
126            source="1.4"
127            classpathref="test.classpath"
128            includes="se/rfc/unbound/" />
129   </target>
130
131   <target name="run-tests" depends="build-tests" if="test.present">
132     <junit printsummary="yes"
133            fork="yes"
134            dir="${test.dir}"
135            timeout="12000">
136       
137       <classpath>
138         <pathelement path="${test.classpath}" />
139       </classpath>
140       
141       <formatter type="plain" />
142
143       <batchtest todir="${test.reports}">
144         <fileset dir="${test.dir}/${build.dest}">
145           <include name="se/rfc/unbound/**/*Test.class" />
146         </fileset>
147       </batchtest>
148     </junit>
149
150   </target>
151
152   <!-- DIST targets -->
153
154   <property name="unbound-proto-distname" 
155             value="unbound-prototype-${version}" />
156
157   <target name="unbound-proto-dist"
158           depends="compile">
159
160     <tar tarfile="${unbound-proto-distname}.tar.gz"
161          compression="gzip">
162       <tarfileset mode="755"
163                   dir="."
164                   prefix="${unbound-proto-distname}">
165         <include name="bin/*.sh" />
166         <exclude name="bin/_*.sh" />
167       </tarfileset>
168
169       <tarfileset dir="."
170                   prefix="${unbound-proto-distname}">
171         <include name="lib/*.jar" />
172         <include name="etc/*.properties" />
173         <include name="etc/named.ca" />
174         <include name="etc/trust_anchors" />
175         <include name="etc/*_trust_anchors" />
176         <include name="VERSION" />
177         <include name="README" />
178         <include name="licenses/**" />
179         <exclude name="bin/**" />
180       </tarfileset>
181
182       <tarfileset dir="${build.lib.dest}"
183                   prefix="${unbound-proto-distname}/lib">
184         <include name="*.jar" />
185       </tarfileset>
186     </tar>
187   </target>
188
189   <target name="unbound-proto-src-dist">
190
191     <tar tarfile="${unbound-proto-distname}-src.tar.gz"
192          compression="gzip">
193
194       <tarfileset mode="755"
195                   dir="."
196                   prefix="${unbound-proto-distname}">
197         <include name="bin/*.sh" />
198       </tarfileset>
199
200       <tarfileset dir="."
201                   prefix="${unbound-proto-distname}">
202         <include name="src/**/*.java" />
203         <include name="dnsjava/**" />
204         <include name="lib/*.jar" />
205         <include name="etc/*.properties" />
206         <include name="etc/named.ca" />
207         <include name="etc/trust_anchors" />
208         <include name="licenses/**" />
209         <include name="VERSION" />
210         <include name="README" />
211         <include name="build.xml" />
212         <exclude name="bin/**" />
213       </tarfileset>
214     </tar>
215
216   </target>
217
218   <target name="sign-dist" 
219           depends="unbound-proto-dist, unbound-proto-src-dist">
220     <exec executable="gpg">
221       <arg value="-a" />
222       <arg value="-s" />
223       <arg value="--detach-sig" />
224       <arg path="${unbound-proto-distname}.tar.gz" />
225     </exec>
226     <exec executable="gpg">
227       <arg value="-a" />
228       <arg value="-s" />
229       <arg value="--detach-sig" />
230       <arg path="${unbound-proto-distname}-src.tar.gz" />
231     </exec>
232     
233   </target>
234
235   <target name="flatten-jar-libs">
236
237     <mkdir dir="${build.dir}/jar" />
238
239     <unjar dest="${build.dir}/jar/">
240       <fileset dir="lib" includes="*.jar" />
241     </unjar>
242
243   </target>
244
245   <target name="unbound-resolver-jar" depends="compile, flatten-jar-libs">
246     
247     <!-- this attempts to make a single runnable jar file for the
248          validating iterative resolver version of this project -->
249     
250     <jar destfile="unbound-resolver.jar">
251       <fileset dir="${build.dest}"
252                includes="se/rfc/unbound/,org/xbill/DNS/" />
253       <fileset dir="${build.dir}/jar"
254                includes="**" />
255       <manifest>
256         <attribute name="Main-Class" value="se.rfc.unbound.server.Server" />
257       </manifest>
258     </jar>
259
260   </target>
261
262   <target name="unbound-digtest-jar" depends="compile, flatten-jar-libs">
263
264     <jar destfile="unbound-digtest.jar">
265       <fileset dir="${build.dest}"
266                includes="se/rfc/unbound/,org/xbill/DNS/" />
267       <fileset dir="${build.dir}/jar"
268                includes="**" />
269       <manifest>
270         <attribute name="Main-Class" value="se.rfc.unbound.cl.DigTest" />
271       </manifest>
272     </jar>
273
274   </target>
275
276   <!-- CLEAN targets -->
277
278   <target name="clean-unbound-proto" depends="prepare-env">
279     <delete dir="${build.dest}" />
280     <delete dir="${build.dir}/jar" />
281     <delete file="${build.lib.dest}/*.jar" />
282   </target>
283
284   <target name="clean-unbound-tests" depends="prepare-env"
285           if="test.present">
286     <delete dir="${test.dir}/${build.dest}" />
287     <delete dir="${test.reports}" />
288   </target>
289
290   <target name="clean-dist" depends="prepare-env">
291     <delete>
292       <fileset dir="." includes="*.tar.gz" />
293     </delete>
294   </target>
295
296
297   <!-- MASTER targets -->
298   <target name="compile"
299           depends="usage, unbound-proto-jar">
300   </target>
301
302   <target name="docs"
303           depends="javadoc-unbound-proto">
304   </target>
305
306   <target name="test"
307           depends="run-tests"
308           if="test.present">
309   </target>
310
311   <target name="dist"
312           depends="usage, unbound-proto-dist, unbound-proto-src-dist">
313   </target>
314
315   <target name="clean" 
316           depends="usage, clean-unbound-proto, clean-unbound-tests, clean-dist">
317   </target>
318
319   <!-- USAGE target -->
320   <target name="usage" depends="prepare-env">
321     <echo message=" " />
322     <echo message="Unbound Prototype v. ${version} Build System" />
323     <echo message="--------------------------------------" />
324     <echo message="Available Targets:" />
325     <echo message="  compile (default) - compiles the source code" />
326     <echo message="  test              - run the unit tests" />
327     <echo message="  dist              - create the distribution files" />
328     <echo message="  clean             - delete class files" />
329     <echo message="  usage             - this help message" />
330     <echo message=" " />
331   </target>
332
333 </project>
334