-
Notifications
You must be signed in to change notification settings - Fork 240
/
build.xml
315 lines (287 loc) · 13 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="simpledb" default="dist" basedir=".">
<property name="src" location="src"/>
<property name="testd" location="test"/>
<property name="build" location="bin"/>
<property name="build.src" location="${build}/src"/>
<property name="build.test" location="${build}/test"/>
<property name="depcache" location="${build}/depcache"/>
<property name="lib" location="lib"/>
<property name="doc" location="javadoc"/>
<property name="dist" location="dist"/>
<property name="jarfile" location="${dist}/${ant.project.name}.jar"/>
<property name="compile.debug" value="true"/>
<property name="test.reports" location="testreport"/>
<property name="sourceversion" value="1.8"/>
<path id="classpath.base">
<pathelement location="${build.src}"/>
<pathelement location="${lib}/zql.jar"/>
<pathelement location="${lib}/jline-0.9.94.jar"/>
<pathelement location="${lib}/mina-core-2.0.4.jar"/>
<pathelement location="${lib}/mina-filter-compression-2.0.4.jar"/>
<pathelement location="${lib}/slf4j-api-1.6.1.jar"/>
<pathelement location="${lib}/slf4j-log4j12-1.6.1.jar"/>
<pathelement location="${lib}/log4j-1.2.17.jar"/>
<pathelement location="${lib}/jzlib-1.0.7.jar"/>
</path>
<path id="classpath.test">
<path refid="classpath.base"/>
<pathelement location="${build.test}"/>
<pathelement location="${lib}/junit-4.13.1.jar"/>
<pathelement location="${lib}/hamcrest-core-1.3.jar"/>
<pathelement location="${lib}/javassist-3.27.0-GA.jar"/>
</path>
<!-- Common macro for compiling Java source -->
<macrodef name="Compile">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<element name="compileoptions" implicit="true" optional="true"/>
<sequential>
<mkdir dir="@{destdir}"/>
<!-- avoids needing ant clean when changing interfaces -->
<depend srcdir="@{srcdir}" destdir="@{destdir}" cache="${depcache}"/>
<javac srcdir="@{srcdir}" destdir="@{destdir}" includeAntRuntime="no"
debug="${compile.debug}" source="${sourceversion}">
<compilerarg value="-Xlint:unchecked" />
<!--<compilerarg value="-Xlint:deprecation" />-->
<compileoptions/>
</javac>
</sequential>
</macrodef>
<!-- Common macro for running junit tests in both the test and runtest targets -->
<macrodef name="RunJunit">
<attribute name="haltonfailure" default="yes" />
<element name="testspecification" implicit="yes" />
<sequential>
<!-- timeout at 10.5 minutes, since TransactionTest is limited to 10 minutes. -->
<junit printsummary="on" fork="yes" timeout="630000" haltonfailure="@{haltonfailure}" maxmemory="128M" failureproperty="junit.failed">
<classpath refid="classpath.test" />
<formatter type="plain" usefile="false"/>
<assertions><enable/></assertions>
<testspecification/>
</junit>
</sequential>
</macrodef>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="eclipse" description="Make current directory an eclipse
project">
<echo file=".project" append="false"><?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>simpledb</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription></echo>
<echo file=".classpath" append="false"><?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/src" path="src/java"/>
<classpathentry kind="src" output="bin/test" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin/src"/>
</echo>
<if> <available file="${lib}/junit-4.13.1.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/junit-4.13.1.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/hamcrest-core-1.3.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/jline-0.9.94.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/jline-0.9.94.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/zql.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/zql.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/mina-core-2.0.4.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/mina-core-2.0.4.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/mina-filter-compression-2.0.4.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/mina-filter-compression-2.0.4.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/jzlib-1.0.7.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/jzlib-1.0.7.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/slf4j-api-1.6.1.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/slf4j-log4j12-1.6.1.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/slf4j-log4j12-1.6.1.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/log4j-1.2.17.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
</echo>
</then>
</if>
<if> <available file="${lib}/javassist-3.27.0-GA.jar" /> <then>
<echo file=".classpath" append="true">
<classpathentry kind="lib" path="lib/javassist-3.27.0-GA.jar"/>
</echo>
</then>
</if>
<echo file=".classpath" append="true">
</classpath>
</echo>
</target>
<target name="compile" description="Compile code">
<Compile srcdir="${src}/java" destdir="${build.src}">
<classpath refid="classpath.base"/>
</Compile>
<copy todir="${build}" flatten="true">
<fileset dir="${src}">
<include name="bin/*.sh"/>
</fileset>
</copy>
</target>
<target name="javadocs" description="Build javadoc documentation">
<javadoc destdir="${doc}" access="private" failonerror="true" source="${sourceversion}" additionalparam="-Xdoclint:none">
<classpath refid="classpath.base" />
<fileset dir="src/java" defaultexcludes="yes">
<include name="simpledb/**/*.java"/>
</fileset>
</javadoc>
</target>
<target name="dist" depends="compile" description="Build jar">
<mkdir dir="${dist}"/>
<jar jarfile="${jarfile}" basedir="${build.src}">
<manifest>
<attribute name="Main-Class" value="simpledb.SimpleDb"/>
<attribute name="Class-Path" value="../lib/zql.jar ../lib/jline-0.9.94.jar ../lib/jzlib-1.0.7.jar ../lib/mina-core-2.0.4.jar ../lib/mina-filter-compression-2.0.4.jar ../lib/slf4j-api-1.6.1.jar ../lib/slf4j-log4j12-1.6.1.jar ../lib/log4j-1.2.17.jar "/>
</manifest>
<!-- Merge library jars into final jar file -->
<!--<zipgroupfileset refid="lib.jars"/>-->
</jar>
</target>
<target name="clean" description="Remove build and dist directories">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="${doc}"/>
<delete dir="${test.reports}"/>
</target>
<target name="testcompile" depends="compile" description="Compile all unit and system tests">
<Compile srcdir="${testd}" destdir="${build.test}">
<classpath refid="classpath.test"/>
</Compile>
</target>
<target name="test" depends="testcompile" description="Run all unit tests">
<RunJunit>
<batchtest>
<fileset dir="${build.test}">
<include name="**/*Test.class"/>
<exclude name="**/*$*.class"/>
<exclude name="simpledb/systemtest/*.class"/>
</fileset>
</batchtest>
</RunJunit>
</target>
<target name="systemtest" depends="testcompile" description="Run all system tests">
<RunJunit>
<batchtest>
<fileset dir="${build.test}">
<include name="simpledb/systemtest/*Test.class"/>
</fileset>
</batchtest>
</RunJunit>
</target>
<target name="runtest" depends="testcompile"
description="Runs the test you specify on the command line with -Dtest=">
<!-- Check for -Dtest command line argument -->
<fail unless="test" message="You must run this target with -Dtest=TestName"/>
<!-- Check if the class exists -->
<available property="test.exists" classname="simpledb.${test}">
<classpath refid="classpath.test" />
</available>
<fail unless="test.exists" message="Test ${test} could not be found"/>
<RunJunit>
<test name="simpledb.${test}"/>
</RunJunit>
</target>
<target name="runsystest" depends="testcompile"
description="Runs the system test you specify on the command line with -Dtest=">
<!-- Check for -Dtest command line argument -->
<fail unless="test" message="You must run this target with -Dtest=TestName"/>
<!-- Check if the class exists -->
<available property="test.exists" classname="simpledb.systemtest.${test}">
<classpath refid="classpath.test" />
</available>
<fail unless="test.exists" message="Test ${test} could not be found"/>
<RunJunit>
<test name="simpledb.systemtest.${test}"/>
</RunJunit>
</target>
<!-- The following target is used for automated grading. -->
<target name="test-report" depends="testcompile"
description="Generates HTML test reports in ${test.reports}">
<mkdir dir="${test.reports}"/>
<!-- do not halt on failure so we always produce HTML reports. -->
<RunJunit haltonfailure="no">
<formatter type="xml"/>
<formatter type="plain" usefile="true"/>
<batchtest todir="${test.reports}" >
<fileset dir="${build.test}">
<include name="**/*Test.class"/>
<exclude name="**/*$*.class"/>
</fileset>
</batchtest>
</RunJunit>
<junitreport todir="${test.reports}">
<fileset dir="${test.reports}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${test.reports}" />
</junitreport>
<!-- Fail here if the junit tests failed. -->
<fail if="junit.failed" message="Some JUnit tests failed"/>
</target>
<target name="handin" depends="clean"
description="Create a tarball of your code to hand in">
<tar destfile="lab-handin.tar.bz2" compression="bzip2"
basedir="." />
<echo message="Tarball created! Please submit 'lab-handin.tar.bz2' per the instructions in the lab document." />
<subant target="dist">
<fileset dir="." includes="build.xml"/>
</subant>
</target>
<target name="test-and-handin" depends="test,systemtest,handin"
description="Run all the tests and system tests; if they succeed, create a tarball of the source code to submit" />
</project>