~ubuntu-branches/ubuntu/trusty/cobertura/trusty

« back to all changes in this revision

Viewing changes to examples/groovy/build.xml

  • Committer: Bazaar Package Importer
  • Author(s): Yulia Novozhilova
  • Date: 2009-06-24 13:56:29 UTC
  • Revision ID: james.westby@ubuntu.com-20090624135629-hgvo8631yye7ofj3
Tags: upstream-1.9
ImportĀ upstreamĀ versionĀ 1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="UTF-8"?>
 
2
 
 
3
<project name="cobertura.examples.basic" default="coverage" basedir=".">
 
4
 
 
5
        <description>
 
6
    Cobertura - http://cobertura.sourceforge.net/
 
7
    Copyright (C) 2003 jcoverage ltd.
 
8
    Copyright (C) 2006 Mark Doliner &lt;thekingant@users.sourceforge.net&gt;
 
9
    Cobertura is licensed under the GNU General Public License
 
10
    Cobertura comes with ABSOLUTELY NO WARRANTY
 
11
    </description>
 
12
 
 
13
        <property file="build.properties" />
 
14
 
 
15
        <path id="cobertura.classpath">
 
16
                <fileset dir="${cobertura.dir}">
 
17
                        <include name="cobertura.jar" />
 
18
                        <include name="lib/**/*.jar" />
 
19
                </fileset>
 
20
        </path>
 
21
 
 
22
        <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
 
23
 
 
24
        <path id="groovy.classpath">
 
25
                <fileset dir="${groovy.dir}">
 
26
                        <include name="*.jar" />
 
27
                </fileset>
 
28
        </path>
 
29
        <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.classpath" />
 
30
 
 
31
        <target name="init">
 
32
                <mkdir dir="${classes.dir}" />
 
33
                <mkdir dir="${instrumented.dir}" />
 
34
                <mkdir dir="${reports.xml.dir}" />
 
35
                <mkdir dir="${reports.html.dir}" />
 
36
                <mkdir dir="${coverage.xml.dir}" />
 
37
                <mkdir dir="${coverage.html.dir}" />
 
38
        </target>
 
39
 
 
40
        <target name="compile" depends="init">
 
41
                <groovyc srcdir="${src.dir}" destdir="${classes.dir}">
 
42
                        <classpath refid="cobertura.classpath" />
 
43
                </groovyc>
 
44
        </target>
 
45
 
 
46
        <target name="instrument" depends="init,compile">
 
47
                <!--
 
48
                        Remove the coverage data file and any old instrumentation.
 
49
                -->
 
50
                <delete file="cobertura.ser"/>
 
51
                <delete dir="${instrumented.dir}" />
 
52
 
 
53
                <!--
 
54
                        Instrument the application classes, writing the
 
55
                        instrumented classes into ${build.instrumented.dir}.
 
56
                -->
 
57
                <cobertura-instrument todir="${instrumented.dir}">
 
58
                        <!--
 
59
                                The following line causes instrument to ignore any
 
60
                                source line containing a reference to log4j, for the
 
61
                                purposes of coverage reporting.
 
62
                        -->
 
63
                        <ignore regex="org.apache.log4j.*" />
 
64
 
 
65
                        <fileset dir="${classes.dir}">
 
66
                                <!--
 
67
                                        Instrument all the application classes, but
 
68
                                        don't instrument the test classes.
 
69
                                -->
 
70
                                <include name="**/*.class" />
 
71
                                <exclude name="**/*Test.class" />
 
72
                        </fileset>
 
73
                </cobertura-instrument>
 
74
        </target>
 
75
 
 
76
        <target name="test" depends="init,compile">
 
77
                <junit fork="yes" dir="${basedir}" failureProperty="test.failed">
 
78
                        <!--
 
79
                                Note the classpath order: instrumented classes are before the
 
80
                                original (uninstrumented) classes.  This is important.
 
81
                        -->
 
82
                        <classpath location="${instrumented.dir}" />
 
83
                        <classpath location="${classes.dir}" />
 
84
 
 
85
                        <!--
 
86
                                The instrumented classes reference classes used by the
 
87
                                Cobertura runtime, so Cobertura and its dependencies
 
88
                                must be on your classpath.
 
89
                        -->
 
90
                        <classpath refid="cobertura.classpath" />
 
91
 
 
92
                        <classpath refid="groovy.classpath" />
 
93
 
 
94
                        <formatter type="xml" />
 
95
                        <test name="com.example.simple.SimpleTest" todir="${reports.xml.dir}" />
 
96
                </junit>
 
97
 
 
98
                <junitreport todir="${reports.xml.dir}">
 
99
                        <fileset dir="${reports.xml.dir}">
 
100
                                <include name="TEST-*.xml" />
 
101
                        </fileset>
 
102
                        <report format="frames" todir="${reports.html.dir}" />
 
103
                </junitreport>
 
104
        </target>
 
105
 
 
106
        <target name="coverage-check">
 
107
                <cobertura-check branchrate="34" totallinerate="100" />
 
108
        </target>
 
109
 
 
110
        <target name="coverage-report">
 
111
                <!--
 
112
                        Generate an XML file containing the coverage data using
 
113
                        the "srcdir" attribute.
 
114
                -->
 
115
                <cobertura-report srcdir="${src.dir}" destdir="${coverage.xml.dir}" format="xml" />
 
116
        </target>
 
117
 
 
118
        <target name="alternate-coverage-report">
 
119
                <!--
 
120
                        Generate a series of HTML files containing the coverage
 
121
                        data in a user-readable form using nested source filesets.
 
122
                -->
 
123
                <cobertura-report destdir="${coverage.html.dir}">
 
124
                        <fileset dir="${src.dir}">
 
125
                                <include name="**/*.groovy"/>
 
126
                        </fileset>
 
127
                </cobertura-report>
 
128
        </target>
 
129
 
 
130
        <target name="clean" description="Remove all files created by the build/test process.">
 
131
                <delete dir="${classes.dir}" />
 
132
                <delete dir="${instrumented.dir}" />
 
133
                <delete dir="${reports.dir}" />
 
134
                <delete file="cobertura.log" />
 
135
                <delete file="cobertura.ser" />
 
136
        </target>
 
137
 
 
138
        <target name="coverage" depends="compile,instrument,test,coverage-report,alternate-coverage-report" description="Compile, instrument ourself, run the tests and generate JUnit and coverage reports."/>
 
139
 
 
140
</project>