File: build.xml

package info (click to toggle)
domesday 0.2cvs20030101-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,344 kB
  • ctags: 1,020
  • sloc: java: 6,454; makefile: 371; modula3: 208; xml: 187; perl: 149; sh: 6
file content (273 lines) | stat: -rw-r--r-- 9,180 bytes parent folder | download | duplicates (2)
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
<?xml version="1.0" encoding="utf-8"?>

<!--
   - $Id: build.xml,v 1.18 2002/09/23 00:40:08 blsecres Exp $
   -	Ant build file
   -->

<project name="Domesday" default="compile" basedir=".">
    <description>
	This is the build file for Domesday.
    </description>


    <property name="progname" value="domesday"/>

    <!--
       - Installation directories
       -->
    <property name="install.prefix" location="/usr/local"/>

    <property name="bin.dir" location="${install.prefix}/bin"/>
    <property name="man1.dir" location="${install.prefix}/share/man/man1"/>
    <property name="man5.dir" location="${install.prefix}/share/man/man5"/>
    <property name="doc.dir"
	    location="${install.prefix}/share/doc/${progname}"/>
    <property name="jar.dir" location="${install.prefix}/share/java"/>

    <!--
       - Local build directories
       -->
    <!-- location of source code -->
    <property name="src" location="${basedir}/src"/>
    <!-- directory to put class files in -->
    <property name="build" location="${basedir}/build"/>
    <!-- directory to put distribution files in -->
    <property name="dist" location="${basedir}/dist"/>
    <!-- directory for api documentation -->
    <property name="docs" location="${basedir}/docs"/>
    <!-- directory for external libraries -->
    <property name="libs" location="${basedir}/lib"/>
    <!-- directory for output -->
    <property name="output" location="${basedir}/output"/>
    <!-- directory for dependency cache -->
    <property name="depend" location="${basedir}/.depend"/>
    <!-- directory for tests -->
    <property name="tests" location="${basedir}/tests"/>

    <!--
       - Dependancy libraries
       -->
    <!-- version of the regular expression library -->
    <property name="regex.ver" value="1.1.4"/>
    <!-- version of the oro regular expression library -->
    <property name="oro.ver" value="2.0.6"/>
    <!-- version of the junit test library -->
    <property name="junit.ver" value="junit3.8"/>


    <!-- set the class path for comilation and execution -->
    <path id="project.class.path">
	<pathelement location="${build}"/>
	<pathelement location="${libs}/gnu-regexp-${regex.ver}.jar"/>
	<pathelement location="${libs}/jakarta-oro-${oro.ver}.jar"/>
    </path>


    <target name="checklibs"
	    description="check the availability of the required libraries">
	<available property="have.${junit.ver}"
		file="${libs}/${junit.ver}.jar"/>
	<available property="have.${oro.ver}"
		file="${libs}/jakarta-oro-${oro.ver}.jar"/>
	<available property="have.regex${regex.ver}"
		file="${libs}/gnu-regexp-${regex.ver}.jar"/>
    </target>


    <target name="getregexp" unless="have.regex${regex.ver}"
	    description="download and extract the regular expression library">
	<!-- make a directory to hold the libraries -->
	<mkdir dir="${libs}"/>
	<!-- download the regexp package -->
	<get
	src="ftp://ftp.tralfamadore.com/pub/java/gnu.regexp-${regex.ver}.tar.gz"
		dest="${libs}/gnu.regexp-${regex.ver}.tar.gz"/>
	<!-- untar the required jar file -->
	<untar src="${libs}/gnu.regexp-${regex.ver}.tar.gz" dest="${libs}"
		compression="gzip">
	    <patternset>
	        <include name="**/lib/gnu-regexp-${regex.ver}.jar"/>
	    </patternset>
	</untar>
	<!-- move the jar file to the proper location -->
	<move
	file="${libs}/gnu.regexp-${regex.ver}/lib/gnu-regexp-${regex.ver}.jar"
		todir="${libs}" overwrite="false"/>
	<!-- remove the untar'ed directories -->
	<delete dir="${libs}/gnu.regexp-${regex.ver}"/>
	<!-- remove the package file -->
	<delete file="${libs}/gnu.regexp-${regex.ver}.tar.gz"/>
    </target>


    <target name="getoro" unless="have.${oro.ver}"
	    description="download and extract the oro regexp library">
	<mkdir dir="${libs}"/>
	<get src="http://jakarta.apache.org/builds/jakarta-oro/release/v${oro.ver}/jakarta-oro-${oro.ver}.tar.gz" dest="${libs}/jakarta-oro-${oro.ver}.tar.gz"/>
	<untar src="${libs}/jakarta-oro-${oro.ver}.tar.gz" dest="${libs}"
		compression="gzip">
	    <patternset>
		<include name="**/jakarta-oro-${oro.ver}.jar"/>
	    </patternset>
	</untar>
	<move file="${libs}/jakarta-oro-${oro.ver}/jakarta-oro-${oro.ver}.jar"
		todir="${libs}" overwrite="false"/>
	<delete dir="${libs}/jakarta-oro-${oro.ver}"/>
	<delete file="${libs}/jakarta-oro-${oro.ver}.tar.gz"/>
    </target>


    <target name="getjunit" unless="have.${junit.ver}"
	    description="download and extract the junit test library">
	<!-- make a directory to hold the libraries -->
	<mkdir dir="${libs}"/>
	<!-- download the package -->
	<get src="http://download.sourceforge.net/junit/${junit.ver}.zip"
		dest="${libs}/${junit.ver}.zip"/>
	<!-- unzip the required jar file -->
	<unzip src="${libs}/${junit.ver}.zip" dest="${libs}"/>
	<!-- move the jar file to the proper location -->
	<move file="${libs}/${junit.ver}/junit.jar"
		tofile="${libs}/${junit.ver}.jar" overwrite="false"/>
	<!-- removed the unzip'd directories -->
	<delete dir="${libs}/${junit.ver}"/>
	<!-- remove the package file -->
	<delete file="${libs}/${junit.ver}.zip"/>
    </target>


    <target name="compile" depends="checklibs,getregexp,getoro"
	    description="compile the source">
	<mkdir dir="${build}"/>
	<mkdir dir="${depend}"/>
	<depend srcDir="${src}" destdir="${build}" cache="${depend}"
	    closure="yes" classpathref="project.class.path"/>
	<javac srcdir="${src}" destdir="${build}" encoding="utf-8"
	    excludes="gui/*"
	    classpathref="project.class.path" debug="true"/>
	<copy todir="${build}" overwrite="no">
	    <fileset dir="${src}" includes="*.properties"/>
	</copy>
    </target>


    <target name="jar" depends="compile"
	    description="create a JAR file for distribution">
	<mkdir dir="${dist}"/>

	<jar destfile="${dist}/${progname}.jar" basedir="${build}"
		includes="*.class,*.properties">
	    <manifest>
		<attribute name="Main-class" value="Domesday"/>
		<attribute name="Class-path" value="file:///${jar.dir}/gnu-regexp-${regex.ver}.jar file:///${jar.dir}/jakarta-oro-${oro.ver}.jar"/>
	    </manifest>
	</jar>
    </target>


    <target name="install" depends="jar" description="install application">
	<mkdir dir="${bin.dir}"/>
	<mkdir dir="${man1.dir}"/>
	<mkdir dir="${man5.dir}"/>
	<mkdir dir="${doc.dir}"/>
	<mkdir dir="${jar.dir}"/>

	<!-- generate a shell script -->
	<echo file="${dist}/${progname}">#!/bin/sh
java -jar ${jar.dir}/${progname}.jar
</echo>

	<copy file="${dist}/${progname}" todir="${bin.dir}"/>
	<chmod file="${bin.dir}/${progname}" perm="555"/>

	<copy file="${dist}/${progname}.jar" todir="${jar.dir}"/>
	<copy file="${libs}/gnu-regexp-${regex.ver}.jar" todir="${jar.dir}"/>
	<copy file="${libs}/jakarta-oro-${oro.ver}.jar" todir="${jar.dir}"/>

	<copy file="doc-user/domesday.1" todir="${man1.dir}"/>
	<copy file="doc-user/domesday.project.5" todir="${man5.dir}"/>

	<copy file="README" todir="${doc.dir}"/>
    </target>


    <target name="runtext" depends="compile"
	    description="run the text mode version of Domesday">
	<mkdir dir="${output}"/>
	<java classname="Domesday" classpathref="project.class.path"
		output="${output}/Domesday.out" failonerror="true">
	    <arg path="${src}/testconfig.ig"/>
	</java>
    </target>


    <target name="docs" description="build documentation">
	<mkdir dir="${docs}"/>
	<!-- TODO add links for java api and regexp api -->
	<javadoc destdir="${docs}" classpathref="project.class.path"
		access="private" version="true" author="true"
		overview="${src}/overview.html">
	    <fileset dir="${src}"/>
	</javadoc>
    </target>


    <target name="clean" description="remove output files">
	<!-- delete the build and distribution directories -->
	<delete dir="${build}"/>
	<delete dir="${docs}"/>
	<delete dir="${dist}"/>
	<delete dir="${depend}"/>
	<delete dir="${output}"/>
	<delete dir="${tests}/build"/>
	<delete dir="${tests}/results"/>
	<delete>
	  <fileset dir="." includes="*.log"/>
	</delete>
    </target>


    <target name="buildtest" depends="compile,getjunit">
	<mkdir dir="${tests}/build"/>
	<javac srcdir="${tests}/src" destdir="${tests}/build" encoding="utf-8"
		classpathref="project.class.path" debug="true">
	    <classpath>
		<pathelement location="${libs}/${junit.ver}.jar"/>
	    </classpath>
	</javac>
    </target>


    <target name="test" depends="buildtest"
	    description="run junit based regression tests">
	<echo>
	    This step may fail is ${junit.ver}.jar is not in the CLASSPATH
	</echo>
	<mkdir dir="${tests}/results"/>
	<junit printsummary="true" failureproperty="tests.failed">
	    <classpath>
		<path refid="project.class.path"/>
		<pathelement location="${tests}/build"/>
	    </classpath>
	    <formatter type="plain"/>
	    <batchtest todir="${tests}/results">
		<fileset dir="${tests}/src"/>
	    </batchtest>
	</junit>
	<fail if="tests.failed"/>
    </target>


    <target name="update" description="update sources via cvs">
	<cvs command="update" compression="true"/>
    </target>


    <target name="commit" depends="update,clean,compile"
	    description="commit sources via cvs">
	<!-- make sure everything is up to date and compiles before
	    commiting -->
	<cvs command="commit" compression="true"/>
    </target>
</project>