1
<?xml version="1.0" encoding="UTF-8"?>
3
<project name="cobertura" default="coverage" basedir="." xmlns:cobertura="antlib:net.sourceforge.cobertura.ant">
6
Cobertura - http://cobertura.sourceforge.net/
7
The copyright for this program is retained by its contributors
8
See the included COPYRIGHT file for a complete list of contributors
9
Cobertura is licensed under the GNU General Public License
10
Cobertura comes with ABSOLUTELY NO WARRANTY
13
<property file="build.properties" />
15
<!-- Import the Cobertura Ant Library -->
16
<property name="cobertura.local.library" location="antLibrary" />
17
<import file="${cobertura.local.library}/library.xml" />
21
<fileset dir="${lib.dir}">
22
<include name="**/*.jar" />
24
<fileset dir="${jetty.dir}">
25
<include name="lib/servlet-api*.jar" />
29
<path id="cobertura.classpath">
30
<pathelement location="cobertura.jar" />
31
<fileset dir="${lib.dir}">
32
<include name="**/*.jar" />
36
<macrodef name="cobertura-taskdef">
38
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
41
This is probably a bug in Eclipse, but the Eclipse ant
42
editor seems to lock the classpath of the last taskdef,
43
so we do a taskdef of one of the core ant tasks so that
44
cobertura.jar does not become locked.
46
<taskdef name="not-used" classname="org.apache.tools.ant.taskdefs.Delete">
48
<pathelement path="${java.class.path}" />
55
<!-- Insert our version number in a file. -->
56
<filter token="version" value="${version}" />
57
<copy file="${etc.dir}/plugin.xml" todir="${build.dir}" filtering="true" overwrite="true" />
60
<target name="compile" depends="init">
61
<mkdir dir="${build.classes.dir}" />
62
<javac fork="true" srcdir="${src.dir}" destdir="${build.classes.dir}" debug="true" encoding="UTF-8"
63
target="${javac.target}">
64
<compilerarg value="-Xlint:unchecked" compiler="javac1.5"/>
65
<classpath location="${build.classes.dir}" />
66
<classpath refid="base.path" />
69
<mkdir dir="${build.otherclasses.dir}" />
70
<javac fork="true" srcdir="${othersrc.dir}" destdir="${build.otherclasses.dir}" debug="true" encoding="UTF-8"
71
target="${javac.target}">
72
<compilerarg value="-Xlint:unchecked" compiler="javac1.5"/>
73
<classpath location="${build.classes.dir}" />
74
<classpath refid="base.path" />
77
<mkdir dir="${build.functionalconditiontest.dir}" />
78
<javac fork="true" srcdir="${examples.functionalconditiontest.dir}" destdir="${build.functionalconditiontest.dir}" debug="true" encoding="UTF-8"
79
target="${javac.target}">
80
<compilerarg value="-Xlint:unchecked" compiler="javac1.5"/>
81
<classpath location="${build.classes.dir}" />
82
<classpath refid="base.path" />
85
<!-- Copy jar resources (css, images, log4j property file, etc.) -->
86
<copy todir="${build.classes.dir}">
87
<fileset dir="${src.dir}">
88
<exclude name="**/*.java" />
93
<target name="compile-tests" depends="init,compile,cobertura-groovy-init">
94
<mkdir dir="${build.test.classes.dir}" />
95
<cobertura:groovyc srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" encoding="UTF-8">
96
<classpath location="${build.classes.dir}" />
97
<classpath location="${build.test.classes.dir}" />
98
<classpath refid="base.path" />
99
<classpath location="${build.otherclasses.dir}" />
100
<classpath location="${build.functionalconditiontest.dir}" />
101
<classpath path="${java.class.path}"/>
102
<javac debug="true" encoding="UTF-8" >
103
<compilerarg value="-Xlint:unchecked" compiler="javac1.5"/>
107
<copy todir="${build.test.classes.dir}">
108
<fileset dir="${test.src.dir}">
109
<exclude name="**/*.java" />
114
<target name="jar" depends="init,compile">
115
<mkdir dir="${build.dist.dir}" />
117
<!-- the standard jar for Cobertura -->
118
<jar jarfile="${basedir}/${ant.project.name}.jar" compress="true">
119
<fileset dir="${build.classes.dir}">
120
<include name="**/*.class" />
122
<fileset dir="${etc.dir}">
123
<include name="log4j.properties" />
124
<include name="tasks.properties" />
126
<fileset dir="${src.dir}">
127
<exclude name="**/*.java" />
128
<exclude name="**/package.html" />
130
<fileset dir="${basedir}">
131
<include name="COPYING" />
132
<include name="COPYRIGHT" />
133
<include name="README" />
136
<attribute name="Specification-Title" value="${description}"/>
137
<attribute name="Specification-Vendor" value="Cobertura"/>
138
<attribute name="Specification-Version" value="${version}"/>
139
<attribute name="Implementation-Title" value="${description}"/>
140
<attribute name="Implementation-Vendor" value="Cobertura"/>
141
<attribute name="Implementation-Vendor-Id" value="net.sourceforge.cobertura"/>
142
<attribute name="Implementation-Version" value="${version}"/>
147
Eclipse needs the ANT tasks and the runtime of Cobertura to be split into
148
separate jars, otherwise lots of bad things happen in eclipse to do with
151
<mkdir dir="${build.dist.eclipse.dir}" />
152
<jar jarfile="${build.dist.eclipse.dir}/${ant.project.name}.jar">
153
<fileset dir="${build.classes.dir}">
154
<include name="net/sourceforge/cobertura/ant/**/*.class" />
156
<fileset dir="${etc.dir}">
157
<include name="tasks.properties" />
160
<attribute name="Specification-Title" value="${description}"/>
161
<attribute name="Specification-Vendor" value="Cobertura"/>
162
<attribute name="Specification-Version" value="${version}"/>
163
<attribute name="Implementation-Title" value="${description}"/>
164
<attribute name="Implementation-Vendor" value="Cobertura"/>
165
<attribute name="Implementation-Vendor-Id" value="net.sourceforge.cobertura"/>
166
<attribute name="Implementation-Version" value="${version}"/>
169
<jar jarfile="${build.dist.eclipse.dir}/${ant.project.name}-main.jar">
170
<fileset dir="${build.classes.dir}">
171
<exclude name="net/sourceforge/cobertura/ant/**/*.class" />
173
<fileset dir="${etc.dir}">
174
<include name="log4j.properties" />
175
<include name="tasks.properties" />
178
<attribute name="Specification-Title" value="${description}"/>
179
<attribute name="Specification-Vendor" value="Cobertura"/>
180
<attribute name="Specification-Version" value="${version}"/>
181
<attribute name="Implementation-Title" value="${description}"/>
182
<attribute name="Implementation-Vendor" value="Cobertura"/>
183
<attribute name="Implementation-Vendor-Id" value="net.sourceforge.cobertura"/>
184
<attribute name="Implementation-Version" value="${version}"/>
189
<target name="war" depends="cobertura-groovy-init">
191
//load buildUtil definitions
192
evaluate(new File("buildUtil.groovy"))
194
buildWar(new File("coberturaFlush.war"))
198
<target name="instrument" depends="jar">
199
<delete file="${basedir}/cobertura.ser" />
200
<delete file="${build.dir}/cobertura.ser" /> <!-- TODO: Is this needed? -->
202
<cobertura-taskdef />
204
<cobertura-instrument datafile="${build.dir}/cobertura.ser" todir="${build.instrumented.dir}">
205
<fileset dir="${build.classes.dir}">
206
<include name="**/*.class" />
207
<exclude name="**/*Test.class" />
208
<exclude name="net/sourceforge/cobertura/javancss/**/*.class" />
210
<fileset dir="${build.otherclasses.dir}">
211
<include name="**/*.class" />
212
<exclude name="**/*Test.class" />
214
</cobertura-instrument>
218
This target is used when testing both instrumented and
219
non-instrumented code. The net.sourceforge.cobertura.datafile
220
sysproperty is only used if we're testing instrumented code.
222
<target name="test" depends="compile-tests">
223
<delete dir="${build.reports.dir}/junit-xml" failonerror="false" />
224
<delete dir="${test.work.dir}" failonerror="false" />
225
<mkdir dir="${build.reports.dir}/junit-xml" />
227
<junit fork="true" forkmode="once" haltonfailure="false" failureProperty="test.failed" printsummary="true" timeout="900000">
228
<sysproperty key="net.sourceforge.cobertura.datafile" file="${build.dir}/cobertura.ser" />
229
<sysproperty key="basedir" value="${basedir}"/>
230
<jvmarg value="-Xmx512M" />
232
<jvmarg value="-Xdebug" />
233
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" />
235
<classpath location="${build.test.classes.dir}" />
236
<classpath location="${build.instrumented.dir}" />
237
<classpath location="${build.classes.dir}" />
238
<classpath location="${build.otherclasses.dir}" />
239
<classpath location="${etc.dir}" />
240
<classpath refid="base.path" />
241
<classpath refid="cobertura.common.local.library" />
243
<fileset dir="${java.home}/../">
244
<include name="lib/tools.jar"/>
247
<formatter type="xml" />
248
<formatter type="plain" usefile="false" />
249
<test name="${testcase}" todir="${build.reports.dir}/junit-xml" if="testcase" />
250
<batchtest todir="${build.reports.dir}/junit-xml" unless="testcase">
251
<fileset dir="${build.test.classes.dir}">
252
<include name="**/*Test.class" />
253
<exclude name="test/first/Test.class" />
254
<exclude name="test/condition/Test.class" />
259
<delete dir="${build.reports.dir}/junit-html" failonerror="false" />
260
<mkdir dir="${build.reports.dir}/junit-html" />
262
<junitreport todir="${build.reports.dir}/junit-html">
263
<fileset dir="${build.reports.dir}/junit-xml">
264
<include name="TEST-*.xml" />
266
<report format="frames" todir="${build.reports.dir}/junit-html" />
271
<target name="coverage-report">
272
<cobertura-taskdef />
274
<delete dir="${build.reports.dir}/coverage-html" failonerror="false" />
275
<mkdir dir="${build.reports.dir}/coverage-html" />
276
<cobertura-report datafile="${build.dir}/cobertura.ser"
277
destdir="${build.reports.dir}/coverage-html"
280
<fileset dir="${src.dir}">
281
<include name="**/*.java" />
283
<fileset dir="${othersrc.dir}">
284
<include name="**/*.java" />
288
<delete dir="${build.reports.dir}/coverage-xml" />
289
<mkdir dir="${build.reports.dir}/coverage-xml" />
290
<cobertura-report datafile="${build.dir}/cobertura.ser"
291
destdir="${build.reports.dir}/coverage-xml"
294
<fileset dir="${src.dir}">
295
<include name="**/*.java" />
297
<fileset dir="${othersrc.dir}">
298
<include name="**/*.java" />
305
<target name="format">
306
<property name="dir.jalopy" value="${lib.dir}/jalopy" />
307
<taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
309
<fileset dir="${dir.jalopy}">
310
<include name="*.jar" />
315
<jalopy fileformat="unix"
316
convention="etc/jalopy.xml"
318
classpathref="base.path">
319
<fileset dir="${src.dir}">
320
<include name="**/*.java" />
322
<fileset dir="${test.src.dir}">
323
<include name="**/*.java" />
329
<target name="javadoc">
330
<delete dir="${build.api.dir}" />
331
<mkdir dir="${build.api.dir}" />
333
<javadoc access="private" author="true" breakiterator="true" destdir="${build.api.dir}" failonerror="true" encoding="UTF-8" linksource="true" serialwarn="false" version="true" windowtitle="Cobertura API">
334
<fileset dir="${src.dir}">
335
<include name="**/*.java" />
337
<classpath location="${ant.home}/lib/ant.jar" />
338
<classpath refid="base.path" />
342
<target name="dist" depends="jar,javadoc">
344
Copy the files needed for the binary jar to a clean directory
345
tree. The "binary" jar contains the minimum files needed to
348
<copy-unix-scripts todir="${build.dist.dir}/package-bin/cobertura-${version}" />
350
<copy todir="${build.dist.dir}/package-bin/cobertura-${version}">
351
<fileset dir="${basedir}">
352
<include name="ChangeLog" />
353
<include name="cobertura-*.bat" />
354
<include name="COPYING" />
355
<include name="COPYRIGHT" />
356
<include name="README" />
357
<include name="lib/**" />
359
<!-- Exclude jars that are only used by the JUnit tests -->
360
<exclude name="lib/jaxen*" />
361
<exclude name="lib/jdom*" />
362
<exclude name="lib/junit*" />
363
<exclude name="lib/xerces/**" />
364
<exclude name="lib/xalan*" />
366
<include name="cobertura.jar" />
367
<include name="coberturaFlush.war" />
368
<include name="examples/basic/README" />
369
<include name="examples/basic/build.properties" />
370
<include name="examples/basic/*.xml" />
371
<include name="examples/basic/src/**" />
376
Copy the files needed for the source jar to a clean directory
377
tree. The "source" jar contains everything needed to build
380
<copy-unix-scripts todir="${build.dist.dir}/package-src/cobertura-${version}" />
382
<copy todir="${build.dist.dir}/package-src/cobertura-${version}">
383
<fileset dir="${basedir}">
384
<include name="antLibrary/**" />
385
<include name="ChangeLog" />
386
<include name="cobertura-*.bat" />
387
<include name="COPYING" />
388
<include name="COPYRIGHT" />
389
<include name="README" />
390
<include name="build.properties" />
391
<include name="build.xml" />
392
<include name="etc/**" />
393
<include name="lib/**" />
394
<include name="resources/**" />
395
<include name="src/**" />
396
<include name="src-2/**" />
397
<include name="test/**" />
399
<include name="examples/*/README" />
400
<include name="examples/*/build.properties" />
401
<include name="examples/*/*.xml" />
402
<include name="examples/*/src/**" />
406
<!-- Create bz2 files -->
407
<create-tar basedir="${build.dist.dir}/package-bin" destfile="${ant.project.name}-${version}-bin.tar.bz2" compression="bzip2"/>
408
<create-tar basedir="${build.dist.dir}/package-src" destfile="${ant.project.name}-${version}-src.tar.bz2" compression="bzip2"/>
410
<!-- Create gz files -->
411
<create-tar basedir="${build.dist.dir}/package-bin" destfile="${ant.project.name}-${version}-bin.tar.gz" compression="gzip"/>
412
<create-tar basedir="${build.dist.dir}/package-src" destfile="${ant.project.name}-${version}-src.tar.gz" compression="gzip"/>
414
<!-- Create zip files -->
415
<create-zip basedir="${build.dist.dir}/package-bin" destfile="${ant.project.name}-${version}-bin.zip"/>
416
<create-zip basedir="${build.dist.dir}/package-src" destfile="${ant.project.name}-${version}-src.zip"/>
418
<!-- Make an Eclipse plugin zip -->
419
<!--<zip destfile="${ant.project.name}-${version}-eclipse-plugin.zip" encoding="UTF-8">
420
<zipfileset prefix="com.${ant.project.name}_${version}" dir="${basedir}">
421
<include name="ChangeLog" />
422
<include name="COPYING" />
423
<include name="COPYRIGHT" />
424
<include name="README" />
425
<include name="lib/**" />
428
<zipfileset prefix="com.${ant.project.name}_${version}" dir="${build.dist.eclipse.dir}">
429
<include name="${ant.project.name}.jar" />
430
<include name="${ant.project.name}-main.jar" />
433
<zipfileset prefix="com.${ant.project.name}_${version}" dir="${etc.dir}">
434
<include name="plugin.properties" />
437
<zipfileset prefix="com.${ant.project.name}_${version}" dir="${build.dir}">
438
<include name="plugin.xml" />
444
<macrodef name="copy-unix-scripts">
445
<attribute name="todir" />
447
<copy todir="@{todir}">
448
<fileset dir="${basedir}">
449
<include name="cobertura-*.sh" />
451
<!-- remove windows carriage returns from unix scripts -->
453
<fixcrlf eof="remove" eol="unix"/>
459
<macrodef name="create-zip">
460
<attribute name="basedir" />
461
<attribute name="destfile" />
463
<zip destfile="@{destfile}" encoding="UTF-8">
464
<zipfileset dir="@{basedir}" filemode="755">
465
<include name="*.sh"/>
467
<zipfileset dir="@{basedir}">
468
<exclude name="*.sh"/>
474
<macrodef name="create-tar">
475
<attribute name="basedir" />
476
<attribute name="destfile" />
477
<attribute name="compression" />
479
<tar destfile="@{destfile}" compression="@{compression}">
480
<tarfileset dir="@{basedir}" mode="755">
481
<include name="*.sh"/>
483
<tarfileset dir="@{basedir}">
484
<exclude name="*.sh"/>
490
<target name="create-bundles" depends="jar,javadoc">
491
<mkdir dir="${build.bundle.dir}" />
494
<fileset dir="${build.bundle.dir}">
499
<mkdir dir="${build.bundle.source.dir}" />
500
<mkdir dir="${build.bundle.runtime.dir}" />
502
<!-- the javadoc jar for Cobertura.
503
used by IDE, maven, and global artifact repository. -->
504
<jar jarfile="${build.bundle.source.dir}/${ant.project.name}-${version}-javadoc.jar" compress="true">
505
<fileset dir="${build.api.dir}">
506
<include name="**/*" />
508
<fileset dir="${basedir}">
509
<include name="COPYING" />
510
<include name="COPYRIGHT" />
511
<include name="README" />
514
<attribute name="Cobertura" value="Javadoc for ${version}"/>
518
<!-- the sources jar for Cobertura.
519
this is not the same as the -src.tar.gz, and is not expected to be
520
a fully compilable source jar.
521
This jar should contain the source for the classes that exist in
522
the cobertura.jar file, and is used from within an IDE to aide
523
in debugging of an application that utilizes that jar file.
524
This is an optional jar file for the global repository. -->
525
<jar jarfile="${build.bundle.source.dir}/${ant.project.name}-${version}-sources.jar" compress="true">
526
<fileset dir="${src.dir}">
527
<include name="**/*" />
529
<fileset dir="${basedir}">
530
<include name="COPYING" />
531
<include name="COPYRIGHT" />
532
<include name="README" />
535
<attribute name="Cobertura" value="Source for ${version}"/>
539
<!-- copy existing files into expected and versioned names -->
540
<copy file="COPYING" tofile="${build.bundle.source.dir}/LICENSE.txt"
542
<copy file="${ant.project.name}.jar"
543
tofile="${build.bundle.source.dir}/${ant.project.name}-${version}.jar"
546
<!-- Create the bundle for the cobertura lib -->
548
<copy file="${basedir}/maven/ibiblio/cobertura.pom"
549
tofile="${build.bundle.source.dir}/pom.xml"
552
<filter token="VERSION" value="${version}" />
557
This bundle jar is only used if the new release is manually uploaded to the
560
<jar jarfile="${basedir}/${ant.project.name}-${version}-bundle.jar" compress="false">
561
<fileset dir="${build.bundle.source.dir}">
562
<include name="LICENSE.txt" />
563
<include name="${ant.project.name}-${version}.jar" />
564
<include name="${ant.project.name}-${version}-javadoc.jar" />
565
<include name="${ant.project.name}-${version}-sources.jar" />
566
<include name="pom.xml" />
570
<!-- Create the bundle for the cobertura-runtime -->
572
<copy file="${basedir}/maven/ibiblio/cobertura-runtime.pom"
573
tofile="${build.bundle.runtime.dir}/pom.xml"
576
<filter token="VERSION" value="${version}" />
580
<copy file="COPYING" tofile="${build.bundle.runtime.dir}/LICENSE.txt"
583
<jar jarfile="${basedir}/${ant.project.name}-runtime-${version}-bundle.jar" compress="false">
584
<fileset dir="${build.bundle.runtime.dir}">
585
<include name="LICENSE.txt" />
586
<include name="pom.xml" />
592
<target name="deploy-to-local-maven-repo-only" depends="cobertura-groovy-init">
594
//load buildUtil definitions
595
evaluate(new File("buildUtil.groovy"))
597
deployToLocalMavenRepo()
602
<target name="install-eclipse-plugin">
603
<apply dir="${eclipse.dir}/plugins" executable="unzip">
606
<include name="${ant.project.name}-${version}-eclipse-plugin.zip" />
611
<target name="clean" description="Remove all files created by the build process.">
612
<delete dir="${build.dir}" />
614
<fileset dir="${basedir}">
615
<include name="cobertura.jar" />
616
<include name="cobertura-*-bundle.jar" />
617
<include name="cobertura.ser" />
618
<include name="cobertura.ser.lock" />
619
<include name="cobertura-*-bin.*" />
620
<include name="cobertura-*-src.*" />
621
<include name="cobertura-*-eclipse-plugin.zip" />
622
<include name="coberturaFlush.war" />
627
<target name="failure-check">
628
<fail message="JUnit tests failed" if="test.failed" />
632
<target name="cobertura-check">
633
<cobertura-check datafile="${build.dir}/cobertura.ser"
635
totallinerate="80" />
640
Used in merging new versions of javancss into Cobertura. See
641
javancss/coberturaREADME.txt for details.
643
<target name="javancss-merge" depends="cobertura-groovy-init">
645
//load buildUtil definitions
646
evaluate(new File("buildUtil.groovy"))
652
<target name="coverage" depends="compile,compile-tests,instrument,test,coverage-report,failure-check,cobertura-check" description="Compile, instrument ourself, run the tests and generate JUnit and coverage reports." />
653
<target name="release" depends="clean,compile,compile-tests,test,failure-check,jar,war,javadoc,dist,create-bundles,deploy-to-local-maven-repo-only" description="Full build cycle, producing a distribution." />
657
vim: et sts=4 sw=4 noexpandtab