-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-test.xml
433 lines (382 loc) · 18.7 KB
/
build-test.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?xml version="1.0"?>
<project name="TopCoder Java Generic Build" default="dist" basedir=".">
<property file="${basedir}/build.version"/>
<property file="../topcoder_global.properties"/>
<!-- Override these in ../topcoder_global.properties -->
<property name="javadoc.locale" value="en_US"/>
<property name="javac.encoding" value="UTF-8"/>
<property name="libdir" value="../tcs/lib"/>
<property name="tcs_libdir" value="${libdir}/tcs"/>
<property name="ext_libdir" value="${libdir}/third_party"/>
<property name="debug" value="off"/>
<property name="verbose" value="no"/>
<property name="cobertura.dir" value="${ext_libdir}/cobertura/1.9"/>
<!-- DIRECTORY SETUP -->
<property name="srcdir" value="src"/>
<property name="docsdir" value="docs"/>
<property name="configdir" value="conf"/>
<property name="testlogdir" value="log"/>
<property name="test_reflib" value="test_reflib"/>
<property name="testfiles" value="test_files"/>
<property name="javadocsdir" value="${docsdir}/javadocs"/>
<property name="reports" value="${testlogdir}/reports"/>
<!-- Import the dependencies of this build file -->
<import file="${basedir}/build-dependencies.xml"/>
<!-- COMPONENT PARAMETERS -->
<property name="component" value="${component.name}"/>
<property name="package" value="${component.package}"/>
<property name="packagedir" value="${component.packagedir}"/>
<property name="distfilename" value="${component.distfilename}"/>
<property name="component_version"
value="${component.version.major}.${component.version.minor}.${component.version.micro}"/>
<property name="component_path" value="${distfilename}/${component_version}"/>
<!-- Change this for custom component build -->
<!--
<property name="greekgod_libdir" value="../lib/greekgod"/>
<property name="target_libdir" value="${greekgod_libdir}"/>
-->
<property name="target_libdir" value="${tcs_libdir}"/>
<!-- DIRECTORY STRUCTURE -->
<property name="javasrc" value="${srcdir}/java"/>
<property name="javamain" value="${javasrc}/main"/>
<property name="javatests" value="${javasrc}/tests"/>
<property name="builddir" value="build"/>
<property name="build_classdir" value="${builddir}/classes"/>
<property name="build_testclassdir" value="${builddir}/testClasses"/>
<property name="build_targetclassdir" value="${builddir}/targetclasses"/>
<property name="build_distdir" value="${builddir}/dist"/>
<property name="build_docsdir" value="${builddir}/${docsdir}"/>
<property name="build_javadocsdir" value="${builddir}/${javadocsdir}"/>
<property name="build_tcsdistdir" value="${build_distdir}/${distfilename}-${component_version}"/>
<property name="manifest_file_path" value="${build_tcsdistdir}/META-INF/"/>
<property name="manifest_file" value="${manifest_file_path}/MANIFEST.MF"/>
<!-- COMPONENT DISTRIBUTION STRUCTURE -->
<property name="dist_lib" value="${build_distdir}/lib/tcs"/>
<property name="dist_docs" value="${build_tcsdistdir}/${docsdir}"/>
<property name="dist_javadocs" value="${build_tcsdistdir}/${javadocsdir}"/>
<property name="dist_coverage" value="${dist_docs}/coverage"/>
<!-- NAME FOR .JAR FILES -->
<property name="component.jar" value="${dist_lib}/${component_path}/${distfilename}.jar"/>
<property name="javadoc.jar" value="javadocs.jar"/>
<property name="component.tests.jar" value="${dist_lib}/${distfilename}_tests.jar"/>
<property name="component.dist.jar" value="${build_distdir}/${distfilename}-${component_version}.jar"/>
<property name="dev_submission.jar" value="${distfilename}_${component_version}_dev_submission.jar"/>
<property name="design_submission.jar" value="${distfilename}_${component_version}_design_submission.jar"/>
<property name="dev_dist.jar" value="${distfilename}_${component_version}_dev_dist.jar"/>
<property name="design_dist.jar" value="${distfilename}_${component_version}_design_dist.jar"/>
<!-- DOCUMENT PACKAGE -->
<property name="dist_docpackage" value="${builddir}/doc_package"/>
<property name="docpackage.jar" value="${distfilename}_docs.jar"/>
<!-- classes needed to compile the production code -->
<path id="buildlibs">
<path refid="component.tcs-dependencies"/>
<path refid="component.3rdParty-dependencies"/>
</path>
<!-- classes needed to compile the test code -->
<path id="test.build.classpath">
<path refid="component.test.3rdParty-dependencies"/>
<fileset dir="${basedir}">
<include name="${test_reflib}/**/*.jar"/>
<include name="${test_reflib}/**/*.zip"/>
</fileset>
<path refid="buildlibs"/>
<pathelement location="${build_classdir}"/>
<pathelement location="${configdir}"/>
<pathelement location="${testfiles}"/>
</path>
<!-- cobertura task definition -->
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura.jar"/>
<include name="lib/**/*.jar"/>
</fileset>
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<property name="cobertura.datafile" value="${testlogdir}/cobertura.ser"/>
<property name="instrumented.dir" value="${builddir}/instrumented"/>
<target name="compile">
<mkdir dir="${build_classdir}"/>
<javac srcdir="${javamain}" destdir="${build_classdir}" includes="${packagedir}/**" debug="true"
verbose="${verbose}" includeAntRuntime="no" encoding="${javac.encoding}">
<classpath refid="buildlibs"/>
</javac>
</target>
<target name="compile_tests" depends="compile">
<mkdir dir="${build_testclassdir}"/>
<javac srcdir="${javatests}" destdir="${build_testclassdir}" includes="${packagedir}/**"
debug="true" verbose="${verbose}" includeAntRuntime="no" encoding="${javac.encoding}">
<classpath refid="test.build.classpath"/>
</javac>
</target>
<macrodef name="compile_targets" description="Compiles the sources and test cases against target JDK">
<attribute name="target"/>
<attribute name="bootclasspath"/>
<sequential>
<mkdir dir="${build_targetclassdir}"/>
<mkdir dir="${javatests}"/>
<javac srcdir="${javamain}" destdir="${build_targetclassdir}" includes="${packagedir}/**"
debug="true" verbose="${verbose}" target="@{target}"
bootclasspath="@{bootclasspath}" extdirs="">
<classpath refid="buildlibs"/>
</javac>
<!-- compile test cases -->
<javac srcdir="${javatests}" destdir="${build_targetclassdir}" includes="${packagedir}/**"
debug="true" verbose="${verbose}" target="@{target}"
bootclasspath="@{bootclasspath}" extdirs="">
<classpath refid="test.build.classpath"/>
</javac>
<delete dir="${build_targetclassdir}"/>
</sequential>
</macrodef>
<target name="compile_targets">
<compile_targets target="${component.target}" bootclasspath="${component.bootclasspath}"/>
</target>
<macrodef name="test.setup">
<sequential/>
</macrodef>
<macrodef name="test.execute">
<!-- standard test task -->
<sequential>
<mkdir dir="${testlogdir}"/>
<junit fork="true" haltonerror="false">
<classpath location="${build_testclassdir}"/>
<classpath refid="test.build.classpath"/>
<test name="${package}.phase.autopilot.AllTests" todir="${testlogdir}">
<formatter type="plain" usefile="true"/>
<formatter type="xml" usefile="true"/>
</test>
</junit>
</sequential>
</macrodef>
<macrodef name="coveragetest.execute">
<!-- standard test task -->
<sequential>
<mkdir dir="${testlogdir}"/>
<mkdir dir="${instrumented.dir}"/>
<delete file="${cobertura.datafile}"/>
<cobertura-instrument todir="${instrumented.dir}" datafile="${cobertura.datafile}">
<!-- all included -->
<fileset dir="${build_classdir}">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
<junit fork="true" haltonerror="false">
<sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.datafile}"/>
<classpath location="${instrumented.dir}"/>
<classpath location="${build_testclassdir}"/>
<classpath refid="test.build.classpath"/>
<classpath refid="cobertura.classpath"/>
<test name="${package}.phase.autopilot.AllTests" todir="${testlogdir}">
<formatter type="plain" usefile="true"/>
<formatter type="xml" usefile="true"/>
</test>
</junit>
</sequential>
</macrodef>
<macrodef name="test.teardown">
<sequential/>
</macrodef>
<target name="test" depends="compile_tests">
<test.setup/>
<test.execute/>
<test.teardown/>
</target>
<target name="coveragetest" depends="compile_tests">
<test.setup/>
<coveragetest.execute/>
<test.teardown/>
</target>
<target name="coveragereport" depends="coveragetest">
<cobertura-report format="html" destdir="${testlogdir}/coverage/" srcdir="${srcdir}"
datafile="${cobertura.datafile}">
<fileset dir="${javamain}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${javatests}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<target name="reports" depends="test">
<mkdir dir="${reports}"/>
<junitreport todir="${reports}">
<fileset dir="${testlogdir}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${reports}"/>
</junitreport>
</target>
<target name="reports-all" depends="coveragereport,reports">
<echo>The execution of reports is complete. Reports are available in /${reports}</echo>
</target>
<target name="manifest">
<mkdir dir="${manifest_file_path}"/>
<manifest file="${manifest_file}">
<attribute name="Component-Vendor" value="TopCoder Inc."/>
<attribute name="Component-Name" value="${component}"/>
<attribute name="Component-Version" value="${component_version}.${component.version.build}"/>
</manifest>
</target>
<target name="dist" depends="compile, manifest">
<mkdir dir="${dist_lib}/${component_path}"/>
<jar jarfile="${component.jar}" manifest="${manifest_file}" basedir="${build_classdir}"/>
</target>
<target name="dist_tests" depends="compile_tests">
<mkdir dir="${dist_lib}"/>
<jar jarfile="${component.tests.jar}" basedir="${build_testclassdir}"/>
</target>
<target name="javadoc" depends="compile">
<mkdir dir="${dist_javadocs}"/>
<javadoc packagenames="${package}.*"
sourcepath="${javamain}"
classpath="${build_classdir}"
classpathref="buildlibs"
destdir="${dist_javadocs}"
windowtitle="Topcoder Software"
header="<table border=0 cellpadding=0 cellspacing=2><tr><td><font class=tcoder2>[ </font><font class=tcoder1>TOP</font><font class=tcoder2>CODER </font><font class=tcoder2>]</font></td><td><font class=tcoder4>™</font></td></tr><tr><td class=tcoder3 align=center><font class=tcoder3>SOFTWARE</font></td></tr></table>"
footer="<table border=0 cellpadding=0 cellspacing=2><tr><td><font class=tcoder2>[ </font><font class=tcoder1>TOP</font><font class=tcoder2>CODER </font><font class=tcoder2>]</font></td><td><font class=tcoder4>™</font></td></tr><tr><td class=tcoder3 align=center><font class=tcoder3>SOFTWARE</font></td></tr></table>"
bottom="<font class=tcoder5>Contact TopCoder Software at <a href='http://software.topcoder.com'>software.topcoder.com</a></font>"
stylesheetfile="${javadocsdir}/stylesheet.css"
locale="${javadoc.locale}"
verbose="${verbose}">
<tag name="copyright" description="Copyright:" scope="types"/>
</javadoc>
</target>
<target name="clean">
<delete dir="${builddir}"/>
<delete dir="${testlogdir}"/>
</target>
<!-- ************************************************************************** -->
<!-- ************ DEPLOYMENT RELATED TARGETS ******************************* -->
<!-- ************************************************************************** -->
<macrodef name="deployCommand">
<!-- standard deploy command -->
<sequential>
<antcall target="dist"/>
</sequential>
</macrodef>
<target name="deploy">
<deployCommand/>
</target>
<target name="deploy-lib" depends="deploy,test">
<mkdir dir="${target_libdir}/${component_path}"/>
<copy file="${component.jar}" todir="${target_libdir}/${component_path}"/>
</target>
<target name="distclean">
<delete dir="${builddir}"/>
</target>
<target name="dist_tcs" depends="distclean,dist,javadoc">
<!-- define tcs distribution format -->
<mkdir dir="${build_tcsdistdir}"/>
<copy todir="${build_tcsdistdir}">
<fileset dir="${basedir}">
<include name="${configdir}/**/*"/>
<include name="${docsdir}/**/*"/>
<include name="${srcdir}/**/*"/>
<include name="${testfiles}/**/*"/>
<include name="${test_reflib}/**/*"/>
<include name="build.version"/>
<include name="build-dependencies.xml"/>
<include name="build-override.xml"/>
<include name="README"/>
<include name="build.version"/>
</fileset>
</copy>
<copy file="build_dist.xml" tofile="${build_tcsdistdir}/build.xml"/>
<mkdir dir="${dist_coverage}"/>
<copy file="${testlogdir}/cobertura.ser" todir="${dist_docs}"/>
<copy todir="${dist_coverage}">
<fileset dir="${testlogdir}/coverage"/>
</copy>
<mkdir dir="${dist_javadocs}"/>
<copy todir="${dist_javadocs}">
<fileset dir="${javadocsdir}"/>
</copy>
<antcall target="package_docs"/>
<jar jarfile="${component.dist.jar}" basedir="${build_distdir}" manifest="${manifest_file}" excludes="*.jar"/>
<antcall target="move_to_tcs"/>
</target>
<target name="package_docs" depends="javadoc">
<mkdir dir="${dist_docpackage}"/>
<jar jarfile="${dist_docpackage}/${javadoc.jar}" basedir="${build_tcsdistdir}/${javadocsdir}"/>
<copy todir="${dist_docpackage}">
<fileset dir="${docsdir}" casesensitive="no">
<include name="${distfilename}_Class_Diagram*"/>
<include name="${distfilename}_Use_Case_Diagram*"/>
<include name="${distfilename}_Sequence_Diagram*"/>
<include name="${distfilename}_Requirements_Specification.pdf"/>
<include name="${distfilename}_Component_Specification.pdf"/>
</fileset>
</copy>
<jar jarfile="${builddir}/${docpackage.jar}" basedir="${dist_docpackage}"/>
</target>
<target name="move_to_tcs">
<mkdir dir="${target_libdir}/${component_path}"/>
<mkdir dir="${target_libdir}/${component_path}/dist"/>
<copy file="${component.jar}" todir="${target_libdir}/${component_path}"/>
<copy file="${component.dist.jar}" todir="${target_libdir}/${component_path}/dist"/>
</target>
<target name="dev_submission" depends="test">
<jar jarfile="${dev_submission.jar}"
basedir="."
includes="build-dependencies.xml,
build-override.xml,
README,
${configdir}/**,
${javamain}/**/*.java,
${javatests}/${packagedir}/**,
${testlogdir}/**,
${testfiles}/**,
${docsdir}/**,
${test_reflib}/**"
excludes="${javatests}/${packagedir}/AllTests.java,
${javatests}/${packagedir}/stresstests/*,
${javatests}/${packagedir}/failuretests/*,
${javatests}/${packagedir}/accuracytests/*"
/>
</target>
<target name="design_submission">
<jar jarfile="${design_submission.jar}"
basedir="."
includes="build-dependencies.xml,
build.version,
build.xml,
${configdir}/**,
${javamain}/**,
${docsdir}/**,
${testfiles}/**"
/>
</target>
<target name="dev_dist">
<!-- copy TCS Dependencies -->
<jar jarfile="${dev_dist.jar}"
basedir="."
includes="build.xml,
README,
build.version,
build-dependencies.xml,
${configdir}/**,
${srcdir}/**,
${docsdir}/**,
${testfiles}/**"
/>
</target>
<target name="design_dist">
<jar jarfile="${design_dist.jar}"
basedir="."
includes="build.xml,
build.version,
build-dependencies.xml,
${configdir}/**,
${srcdir}/**,
${docsdir}/**,
${testfiles}/**"
/>
</target>
<!-- ************************************************************************** -->
<!-- ************ END DEPLOYMENT RELATED TARGETS *************************** -->
<!-- ************************************************************************** -->
<!-- Import the macro definitions used to override standard behaviour of
some of the targets of this build file. -->
<import file="${basedir}/build-override.xml" optional="true"/>
</project>