-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.xml
196 lines (169 loc) · 7.73 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="simpledb" default="dist">
<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.5"/>
<path id="classpath.base">
<pathelement location="${build.src}"/>
<pathelement location="${lib}/zql.jar"/>
<pathelement location="${lib}/jline-0.9.94.jar"/>
</path>
<path id="classpath.test">
<path refid="classpath.base"/>
<pathelement location="${build.test}"/>
<pathelement location="${lib}/junit-4.5.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="src" destdir="${destdir}" cache="${depcache}"/>
<javac srcdir="src" 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>
<target name="compile" description="Compile code">
<Compile srcdir="${src}" destdir="${build.src}">
<classpath refid="classpath.base"/>
</Compile>
</target>
<target name="javadocs" description="Build javadoc documentation">
<javadoc destdir="${doc}" access="private" failonerror="true" source="${sourceversion}">
<classpath refid="classpath.base" />
<fileset dir="src" 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"/>
</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}"/>
</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." />
</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>