-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
556 lines (474 loc) · 22.1 KB
/
build.xml
File metadata and controls
556 lines (474 loc) · 22.1 KB
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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<?xml version="1.0" ?>
<project default="build">
<loadproperties srcfile="build.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="external/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="build" depends="init,compile,dist,tar"
description="build dtf">
<echo>DTF build at ${basedir}/${dtf.build.dir}/${dtf.dist.dir}</echo>
</target>
<target name="tar">
<tar basedir="${dtf.build.dir}/${dtf.dist.dir}"
tarfile="${dtf.build.dir}/dtf.tar.gz"
compression="gzip"/>
</target>
<target name="init" description="initialize target">
<mkdir dir="${dtf.build.dir}"/>
<mkdir dir="${dtf.build.dir}/${dtf.classes.dir}"/>
<mkdir dir="${dtf.build.dir}/${dtf.dist.dir}"/>
<mkdir dir="${dtf.build.dir}/${dtf.dist.dir}/lib"/>
<mkdir dir="${dtf.build.dir}/${dtf.dist.dir}/tests"/>
<path id="dtf.classpath">
<fileset id="dtf.fileset" dir="${dtf.ext.lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="external">
<include name="**/*.jar"/>
</fileset>
<fileset file="${dtf.build.dir}/${dtf.dist.dir}/lib/dtf.jar"/>
</path>
</target>
<target name="junit.init">
<!-- check junit is correctly setup -->
<available file="${junit.home}" type="dir" property="junit.ready"/>
<if>
<isset property="junit.ready"/>
<then>
<property name="javac.excludes" value=""/>
<path id="junit.classpath">
<fileset dir="${junit.home}">
<include name="*.jar" />
</fileset>
</path>
</then>
<else>
<property name="javac.excludes" value="**/junit/**"/>
<path id="junit.classpath"/>
<echo>JUnit not tests not being compiled</echo>
</else>
</if>
</target>
<target name="compile" depends="junit.init" description="Compilation target">
<javac srcdir="${dtf.src.dir}/java"
destdir="${dtf.build.dir}/${dtf.classes.dir}"
debug="on"
target="${dtf.java.target}"
debuglevel="lines,vars,source"
encoding="ISO-8859-1"
excludes="${javac.excludes}"
classpath="${junit.lib}">
<classpath refid="dtf.classpath"/>
<classpath refid="junit.classpath"/>
</javac>
<tstamp>
<!-- build id -->
<format property="build.id" pattern="yyyyMMddHHmmssSZ"/>
</tstamp>
<echo file="${dtf.build.dir}/${dtf.classes.dir}/build.id">${build.id}</echo>
<copy todir="${dtf.build.dir}/${dtf.classes.dir}">
<fileset dir="src">
<include name="xsl/**"/>
</fileset>
</copy>
</target>
<target name="distplugins" depends="init" description="distribution target">
<!-- Handle plugins in plugin directory -->
<for list="${dtf.plugins}" delimiter=":" param="plugin.location">
<sequential>
<basename property="plugin.name" file="@{plugin.location}"/>
<ant antfile="build.xml"
target="build_plugin"
dir="@{plugin.location}">
<property name="dtf.dist"
value="${dtf.dir}/${dtf.build.dir}/${dtf.dist.dir}"/>
<property name="dtf.jar"
value="${dtf.dir}/${dtf.build.dir}/${dtf.dist.dir}/lib/${dtf.jar.filename}"/>
<property name="build.dir"
value="${dtf.dir}/${dtf.build.dir}/${plugin.name}"/>
</ant>
<echo>Merging plugin XSD with DTF XSD</echo>
<java classname="com.yahoo.dtf.plugin.PluginMerger"
failonerror="true" fork="true">
<arg value="${dtf.build.dir}/${plugin.name}/dist"/>
<arg value="${dtf.xsd.filename}"/>
<arg value="${dtf.build.dir}/${dtf.dist.dir}"/>
<sysproperty key="dtf.home" value="${dtf.build.dir}/${dtf.dist.dir}"/>
<classpath refid="dtf.classpath"/>
<classpath>
<pathelement location="${dtf.build.dir}/${dtf.dist.dir}/lib/${dtf.jar.filename}"/>
</classpath>
</java>
<!-- we only copy lib directory and tests directory the other
files put here by the plugin better be source files to
be picked up by the javadoc otherwise they're not part
of the final distribution being built. -->
<echo>Copying plugin ${plugin.name} to ${dtf.dist.dir}</echo>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}">
<fileset dir="${dtf.build.dir}/${plugin.name}/dist">
<include name="**/lib/**"/>
</fileset>
</copy>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/tests/${plugin.name}">
<fileset dir="@{plugin.location}/tests"/>
</copy>
<!-- overwrite is set to true so that plugins can easily
overwrite existing files in DTF -->
<copy todir="${dtf.build.dir}/${dtf.dist.dir}" overwrite="true">
<fileset dir="${dtf.build.dir}/${plugin.name}/dist/bin"/>
</copy>
<!-- set the permissions of the stuff I just copied into the
bin directory back to executable (since stupid ant task
removes the executable permissions) -->
<chmod perm="555"
includes="*"
excludes="*.properties,*.xsd,*.xml,*.txt"
dir="${dtf.build.dir}/${dtf.dist.dir}"/>
</sequential>
</for>
</target>
<target name="dist" description="distribution target">
<jar jarfile="${dtf.build.dir}/${dtf.dist.dir}/lib/${dtf.jar.filename}"
basedir="${dtf.build.dir}/${dtf.classes.dir}"
includes="**/**"/>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/lib">
<fileset refid="dtf.fileset"/>
</copy>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}" overwrite="true">
<fileset dir="${dtf.src.dir}/scripts"/>
<fileset file="${dtf.src.dir}/config/dtf.properties"/>
<fileset file="${dtf.src.dir}/config/policy.txt"/>
<fileset file="dtf.xsd"/>
</copy>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/tests">
<fileset dir="tests"/>
</copy>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/xsl">
<fileset dir="src/xsl"/>
</copy>
<copy tofile="${dtf.build.dir}/${dtf.dist.dir}/build.xml" file="run.xml"/>
<!-- put the current copy of ant for distribution -->
<unzip src="${dtf.ant.zip}" dest="${dtf.build.dir}/${dtf.dist.dir}"/>
<!-- clean up stupid docs in apache (not necesary for distribution) -->
<delete>
<fileset dir="${dtf.build.dir}/${dtf.dist.dir}" includes="**/apache*/docs/**"/>
</delete>
<antcall target="distplugins"/>
<!-- permissions fixing... ugly ugly... -->
<chmod perm="555"
includes="**/ant,**/antRun,*.sh,*.php"
dir="${dtf.build.dir}/${dtf.dist.dir}"/>
</target>
<target name="clean" description="clean target">
<delete dir="${dtf.build.dir}" failonerror="true"/>
</target>
<target name="unittests"
depends="build"
description="run dtf unit tests">
<ant antfile="build.xml"
dir="${dtf.build.dir}/${dtf.dist.dir}"
target="run_ut"
/>
</target>
<target name="deploy"
depends="init,tar"
description="Deploys the current build to a list of machines">
<property environment="env"/>
<if>
<not>
<isset property="deploy.user"/>
</not>
<then>
<property name="deploy.user" value="${env.USER}"/>
</then>
</if>
<if>
<not>
<isset property="deploy.pass"/>
</not>
<then>
<property name="deploy.pass" value="NOTSET"/>
</then>
</if>
<java classname="com.yahoo.dtf.deploy.Deploy"
failonerror="true">
<arg value="${deploy.user}"/>
<arg value="${deploy.pass}"/>
<arg value="${deploy.hosts}"/>
<arg value="${env.HOME}"/>
<arg value="${dtf.dir}/${dtf.build.dir}/dtf.tar.gz"/>
<classpath refid="dtf.classpath"/>
</java>
<echo>
DTF has been copied to your home directory on ${deploy.hosts}
</echo>
</target>
<target name="doc"
depends="init,build"
description="Generate both Java and DTF XML documentation.">
<mkdir dir="${dtf.build.dir}/${dtf.dist.dir}/doc/html"/>
<path id="javadoc.classpath">
<fileset dir="${dtf.build.dir}/${dtf.dist.dir}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- DTF XML DOCS -->
<javadoc destdir="${dtf.build.dir}/${dtf.dist.dir}/doc/html/dtf"
access="private"
classpathref="javadoc.classpath"
docletpathref="javadoc.classpath"
>
<!--
using the ${dtf.dir} property we can tell it the absolute location
of the xsd
-->
<arg line="-dtfxsd ${basedir}/${dtf.build.dir}/${dtf.dist.dir}/dtf.xsd"/>
<doclet name="com.yahoo.dtf.javadoc.DTFDoclet"
path="${dtf.build.dir}/${dtf.dist.dir}/lib/${dtf.jar.filename}"/>
<fileset dir="${dtf.src.dir}" defaultexcludes="true">
<include name="**/**/*.java"/>
</fileset>
<fileset dir="${dtf.build.dir}" defaultexcludes="true">
<include name="**/**/*.java"/>
</fileset>
</javadoc>
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/doc/html/dtf"
file="src/main.css"/>
<tar basedir="${dtf.build.dir}/${dtf.dist.dir}/doc/html/dtf"
destfile="${dtf.build.dir}/${dtf.dist.dir}/doc.tgz"
compression="gzip"
includes="**/**"/>
<echo>XML Documentation at ${basedir}/${dtf.build.dir}/${dtf.dist.dir}/doc</echo>
<!-- JAVA API DOCS -->
<!--
<javadoc destdir="${dtf.build.dir}/${dtf.dist.dir}/doc/html/api">
<arg line="-tag dtf.tag:a"/>
<arg line="-tag dtf.tag.desc:a"/>
<arg line="-tag dtf.author:a"/>
<arg line="-tag dtf.since:a"/>
<arg line="-tag dtf.attr:a"/>
<arg line="-tag dtf.attr.desc:a"/>
<arg line="-tag dtf.event:a"/>
<arg line="-tag dtf.event.attr:a"/>
<arg line="-tag dtf.event.attr.desc:a"/>
<arg line="-tag dtf.tag.example:a"/>
<fileset dir="${dtf.src.dir}" defaultexcludes="true">
<include name="**/actions/**/*.java"/>
</fileset>
<fileset dir="${dtf.build.dir}" defaultexcludes="true">
<include name="**/actions/**/*.java"/>
</fileset>
<classpath>
<fileset dir="${dtf.build.dir}/${dtf.dist.dir}/lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javadoc>
-->
</target>
<target name="findbugs" depends="init">
<!-- check findbugs is correctly setup -->
<available file="${findbugs.home}" type="dir" property="finbugs.ready"/>
<if>
<isset property="findbugs.ready"/>
<then>
<taskdef name="findbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
</classpath>
</taskdef>
<property environment="env"/>
<findbugs home="${findbugs.home}"
output="xml"
outputFile="${dtf.build.dir}/${dtf.dist.dir}/findbugs.xml"
jvmargs="-Xmx512m">
<auxclasspath refid="dtf.classpath"/>
<auxclasspath path="${env.JAVA_HOME}/lib/tools.jar"/>
<sourcePath path="${dtf.dir}/src/java"/>
<class location="${dtf.build.dir}/classes"/>
</findbugs>
</then>
<else>
<fail message="Findbugs home not set, see build.properties file"/>
</else>
</if>
</target>
<target name="cobertura-instrument" depends="init">
<!-- check cobertura is correctly setup -->
<available file="${cobertura.home}" type="dir" property="cobertura.ready"/>
<if>
<isset property="cobertura.ready"/>
<then>
<path id="cobertura.classpath">
<fileset dir="${cobertura.home}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath"
resource="tasks.properties" />
<delete file="cobertura.ser"/>
<delete dir="${dtf.build.dir}/iclasses"/>
<mkdir dir="${dtf.build.dir}/iclasses"/>
<cobertura-instrument todir="${dtf.build.dir}/classes">
<ignore regex="org.apache.log4j.*"/>
<fileset dir="${dtf.build.dir}/classes">
<include name="**/*.class"/>
<!-- deploy code can't be tested without a dependency on another
machine to deploy to -->
<exclude name="com/yahoo/dtf/deploy/*.class"/>
<!-- plugin merger only run at build time, no easy way to
integrate with unit test for the time being -->
<exclude name="com/yahoo/dtf/plugin/*.class"/>
<!-- exception coverage doesn't matter -->
<exclude name="com/yahoo/dtf/exception/*.class"/>
<!-- same as plugin merger, the javadoc is done at build time -->
<exclude name="com/yahoo/dtf/javadoc/*.class"/>
<!-- JSON Library is not my responsibility to unit test -->
<exclude name="com/yahoo/dtf/json/*.class"/>
</fileset >
</cobertura-instrument>
<!-- copy cobertura jar into this build as well -->
<copy todir="${dtf.build.dir}/${dtf.dist.dir}/lib">
<fileset dir="${cobertura.home}">
<include name="*.jar"/>
</fileset>
</copy>
<delete file="${dtf.build.dir}/${dtf.dist.dir}/lib/dtf.jar"/>
<antcall target="dist"/>
</then>
<else>
<fail message="Cobertura home not set correctly, see build.properties file"/>
</else>
</if>
</target>
<target name="cobertura-report" depends="init">
<!-- check cobertura is correctly setup -->
<available file="${cobertura.home}" type="dir" property="cobertura.ready"/>
<if>
<isset property="cobertura.ready"/>
<then>
<path id="cobertura.classpath">
<fileset dir="${cobertura.home}">
<include name="cobertura.jar" />
<include name="lib/**/*.jar" />
</fileset>
</path>
<taskdef classpathref="cobertura.classpath"
resource="tasks.properties" />
<cobertura-merge>
<fileset dir="${dtf.build.dir}/${dtf.dist.dir}">
<include name="*.ser" />
</fileset>
</cobertura-merge>
<cobertura-report format="xml"
srcdir="${dtf.build.dir}/${dtf.dist.dir}"
destdir="${dtf.build.dir}/cobertura">
<fileset dir="src/java">
<include name="**/*.java" />
</fileset>
</cobertura-report>
<cobertura-report format="html"
srcdir="${dtf.build.dir}/${dtf.dist.dir}"
destdir="${dtf.build.dir}/cobertura">
<fileset dir="src/java">
<include name="**/*.java" />
</fileset>
</cobertura-report>
</then>
<else>
<fail message="Cobertura home not set correctly, see build.properties file"/>
</else>
</if>
</target>
<target name="junit" depends="junit.init">
<!-- check junit is correctly setup -->
<available file="${junit.home}" type="dir" property="junit.ready"/>
<if>
<isset property="junit.ready"/>
<then>
<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath refid="junit.classpath"/>
</taskdef>
<mkdir dir="${dtf.build.dir}/junit_results"/>
<path id="dtf.classpath">
<fileset dir="${dtf.build.dir}/${dtf.dist.dir}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="external">
<include name="*.jar"/>
</fileset>
</path>
<if>
<isset property="junit.test"/>
<then>
<junit printsummary="yes"
showoutput="true"
dir="${dtf.dir}"
haltonerror="true"
haltonfailure="true"
>
<jvmarg line="-enableassertions"/>
<sysproperty key="dtf.home"
value="${basedir}/${dtf.build.dir}/${dtf.dist.dir}"/>
<sysproperty key="net.sourceforge.cobertura.datafile"
value="${basedir}/${dtf.build.dir}/${dtf.dist.dir}/cobertura-junit.ser" />
<syspropertyset>
<propertyref builtin="commandline"/>
</syspropertyset>
<classpath refid="dtf.classpath"/>
<classpath refid="junit.classpath"/>
<formatter type="xml"/>
<test name="com.yahoo.dtf.junit.${junit.test}"
outfile="${dtf.build.dir}/junit_results/${junit.test}"
fork="true" />
</junit>
</then>
<else>
<junit printsummary="yes"
showoutput="true"
dir="${dtf.dir}"
haltonerror="true"
haltonfailure="true"
>
<jvmarg line="-enableassertions"/>
<sysproperty key="dtf.home"
value="${basedir}/${dtf.build.dir}/${dtf.dist.dir}"/>
<sysproperty key="net.sourceforge.cobertura.datafile"
value="${basedir}/${dtf.build.dir}/${dtf.dist.dir}/cobertura-junit.ser" />
<syspropertyset>
<propertyref builtin="commandline"/>
</syspropertyset>
<classpath refid="dtf.classpath"/>
<classpath refid="junit.classpath"/>
<formatter type="xml"/>
<batchtest fork="true"
todir="${dtf.build.dir}/junit_results">
<fileset dir="${dtf.build.dir}/${dtf.classes.dir}">
<include name="**/junit/*.class"/>
</fileset>
</batchtest>
</junit>
</else>
</if>
</then>
<else>
<fail message="junit home not set correctly, see build.properties file"/>
</else>
</if>
</target>
<target name="junit-reports">
<mkdir dir="${dtf.build.dir}/reports"/>
<mkdir dir="${dtf.build.dir}/reports/html"/>
<junitreport todir="${dtf.build.dir}/reports">
<fileset dir="${dtf.build.dir}">
<include name="**/TEST*.xml"/>
</fileset>
<report format="frames" todir="${dtf.build.dir}/reports/html"/>
</junitreport>
</target>
</project>