Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="ISO-8859-1" ?>
|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
| 4 | <head>
|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
| 6 | <link rel="stylesheet" href=".resources/doc.css" charset="ISO-8859-1" type="text/css" />
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 7 | <link rel="stylesheet" href="../coverage/.resources/prettify.css" charset="ISO-8859-1" type="text/css" />
|
Marc R. Hoffmann | d7d2f75 | 2010-05-06 21:12:31 +0000 | [diff] [blame] | 8 | <link rel="shortcut icon" href=".resources/report.gif" type="image/gif" />
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 9 | <script type="text/javascript" src="../coverage/.resources/prettify.js"></script>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 10 | <title>JaCoCo - Ant Tasks</title>
|
| 11 | </head>
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 12 | <body onload="prettyPrint()">
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 13 |
|
| 14 | <div class="breadcrumb">
|
Marc R. Hoffmann | d7d2f75 | 2010-05-06 21:12:31 +0000 | [diff] [blame] | 15 | <a href="../index.html" class="el_report">JaCoCo</a> >
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 16 | <a href="index.html" class="el_group">Documentation</a> >
|
| 17 | <span class="el_source">Ant Tasks</span>
|
| 18 | </div>
|
Marc R. Hoffmann | 17be269 | 2010-02-02 05:44:47 +0000 | [diff] [blame] | 19 | <div id="content">
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 20 |
|
| 21 | <h1>Ant Tasks</h1>
|
| 22 |
|
| 23 | <p>
|
| 24 | JaCoCo comes with Ant tasks to launch Java programs with execution recording
|
Marc R. Hoffmann | b8a7746 | 2009-08-21 14:53:50 +0000 | [diff] [blame] | 25 | and for creating coverage reports from the recorded data. The JaCoCo Ant tasks
|
| 26 | require
|
| 27 | </p>
|
| 28 |
|
| 29 | <ul>
|
| 30 | <li>Ant 1.7.0 or higher and</li>
|
| 31 | <li>Java 1.5 or higher (for both, the Ant runner and the test executor).</li>
|
| 32 | </ul>
|
| 33 |
|
| 34 |
|
Marc R. Hoffmann | 57f9ab4 | 2009-08-24 10:52:42 +0000 | [diff] [blame] | 35 | <p>All tasks are defined in <code>jacocoant.jar</code> (which is part of the
|
| 36 | distribution) and can be included in your Ant scripts with the usual
|
| 37 | <code>taskdef</code> declaration:
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 38 | </p>
|
| 39 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 40 | <pre class="source lang-xml">
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 41 | <span class="nr"> 1</span><project name="Example" xmlns:jacoco="antlib:org.jacoco.ant">
|
| 42 | <span class="nr"> 2</span>
|
| 43 | <span class="nr"> 3</span> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
|
| 44 | <span class="nr"> 4</span> <classpath>
|
Marc R. Hoffmann | db93077 | 2009-08-20 17:17:37 +0000 | [diff] [blame] | 45 | <span class="nr"> 5</span> <pathelement location="<i>path_to_jacoco</i>/lib/jacocoant.jar"/>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 46 | <span class="nr"> 6</span> </classpath>
|
| 47 | <span class="nr"> 7</span> </taskdef>
|
| 48 | <span class="nr"> 8</span>
|
| 49 | <span class="nr"> 9</span> ...
|
| 50 | <span class="nr"> 10</span>
|
| 51 | <span class="nr"> 11</span></project>
|
| 52 | </pre>
|
| 53 |
|
| 54 | <p>
|
Marc R. Hoffmann | db3e7d0 | 2009-08-12 10:57:39 +0000 | [diff] [blame] | 55 | Alternatively you might also place the <code>jacocoant.jar</code> in your
|
| 56 | Ant <code><i>ANT_HOME</i>/lib</code> folder. If you use the name space URI
|
| 57 | <code>antlib:org.jacoco.ant</code> for JaCoCo tasks Ant will find them
|
| 58 | automatically without the <code>taskdef</code> declaration above.
|
| 59 | </p>
|
| 60 |
|
| 61 | <p>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 62 | Declaring a XML namespace for JaCoCo tasks is optional but always recommended
|
| 63 | if you mix tasks from different libraries. All subsequent examples use the
|
| 64 | <code>jacoco</code> prefix declared above.
|
| 65 | </p>
|
| 66 |
|
| 67 |
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 68 | <h2><a name="coverage">Task <code>coverage</code></a></h2>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 69 |
|
| 70 | <p>
|
| 71 | The standard Ant tasks to launch Java programs are <code>java</code> and
|
| 72 | <code>junit</code>. To add code coverage recording to these tasks they can
|
| 73 | simply be wrapped with the <code>coverage</code> task as shown in the
|
| 74 | following examples:
|
| 75 | </p>
|
| 76 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 77 | <pre class="source lang-xml">
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 78 | <span class="nr"> 1</span><jacoco:coverage>
|
| 79 | <span class="nr"> 2</span> <java classname="org.jacoco.examples.HelloJaCoCo" fork="true">
|
| 80 | <span class="nr"> 3</span> <classpath>
|
| 81 | <span class="nr"> 4</span> <pathelement location="./bin"/>
|
| 82 | <span class="nr"> 5</span> </classpath>
|
| 83 | <span class="nr"> 6</span> </java>
|
| 84 | <span class="nr"> 7</span></jacoco:coverage>
|
| 85 | <span class="nr"> 8</span>
|
| 86 | <span class="nr"> 9</span>
|
| 87 | <span class="nr"> 10</span><jacoco:coverage>
|
| 88 | <span class="nr"> 11</span> <junit fork="true" forkmode="once">
|
| 89 | <span class="nr"> 12</span> <test name="org.jacoco.examples.HelloJaCoCoTest"/>
|
| 90 | <span class="nr"> 13</span> <classpath>
|
| 91 | <span class="nr"> 14</span> <pathelement location="./bin"/>
|
| 92 | <span class="nr"> 15</span> </classpath>
|
| 93 | <span class="nr"> 16</span> </junit>
|
| 94 | <span class="nr"> 17</span></jacoco:coverage>
|
| 95 | </pre>
|
| 96 |
|
| 97 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 98 | Resulting coverage information is collected during execution and written
|
| 99 | to a file when the process terminates. Note the <code>fork</code> attribute
|
| 100 | above in the wrapped <code>java</code> task.
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 101 | </p>
|
| 102 |
|
| 103 | <p class="hint">
|
| 104 | The nested task always has to declare <code>fork="true"</code>, otherwise the
|
| 105 | <code>coverage</code> task can't record coverage information and will fail.
|
| 106 | In addition the <code>junit</code> task should declare
|
| 107 | <code>forkmode="once"</code> to avoid starting a new JVM for every single test
|
| 108 | case and decreasing execution performance dramatically (unless this is
|
| 109 | required by the nature of the test cases).
|
| 110 | </p>
|
| 111 |
|
| 112 | <p>
|
| 113 | The coverage task must wrap exactly one task. While it typically works without
|
| 114 | any configuration, the behavior can be adjusted with some optional attributes:
|
| 115 | </p>
|
| 116 |
|
| 117 | <table class="coverage">
|
| 118 | <thead>
|
| 119 | <tr>
|
| 120 | <td>Attribute</td>
|
| 121 | <td>Description</td>
|
| 122 | <td>Default</td>
|
| 123 | </tr>
|
| 124 | </thead>
|
| 125 | <tbody>
|
| 126 | <tr>
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 127 | <td><code>enabled</code></td>
|
| 128 | <td>If set to <code>true</code> coverage data will be collected for the contained task.</td>
|
| 129 | <td><code>true</code></td>
|
| 130 | </tr>
|
Marc R. Hoffmann | e3ef2f3 | 2010-01-28 18:17:46 +0000 | [diff] [blame] | 131 | <tr>
|
Brock Janiczak | 003d47c | 2010-01-15 00:45:17 +0000 | [diff] [blame] | 132 | <td><code>destfile</code></td>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 133 | <td>Path to the output file for execution data.</td>
|
| 134 | <td><code>jacoco.exec</code></td>
|
| 135 | </tr>
|
| 136 | <tr>
|
Brock Janiczak | 003d47c | 2010-01-15 00:45:17 +0000 | [diff] [blame] | 137 | <td><code>append</code></td>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 138 | <td>If set to <code>true</code> and the execution data file already
|
Brock Janiczak | 003d47c | 2010-01-15 00:45:17 +0000 | [diff] [blame] | 139 | exists, coverage data is appended to the existing file. If set to
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 140 | <code>false</code>, an existing execution data file will be replaced.
|
| 141 | </td>
|
| 142 | <td><code>true</code></td>
|
| 143 | </tr>
|
| 144 | <tr>
|
Marc R. Hoffmann | cf5345f | 2009-09-10 15:01:24 +0000 | [diff] [blame] | 145 | <td><code>includes</code></td>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 146 | <td>A list of class names that should be included in execution analysis.
|
Marc R. Hoffmann | cf5345f | 2009-09-10 15:01:24 +0000 | [diff] [blame] | 147 | The list entries are separated by a vertical bar (<code>|</code>) and
|
| 148 | may use wildcard characters (<code>*</code> and <code>?</code>).
|
| 149 | Except for performance optimization or technical corner cases this
|
| 150 | option is normally not required.
|
| 151 | </td>
|
| 152 | <td><code>*</code> (all classes)</td>
|
| 153 | </tr>
|
| 154 | <tr>
|
| 155 | <td><code>excludes</code></td>
|
| 156 | <td>A list of class names that should be excluded from execution analysis.
|
| 157 | The list entries are separated by a vertical bar (<code>|</code>) and
|
| 158 | may use wildcard characters (<code>*</code> and <code>?</code>).
|
| 159 | Except for performance optimization or technical corner cases this
|
| 160 | option is normally not required.
|
| 161 | </td>
|
| 162 | <td><i>empty</i> (no excluded classes)</td>
|
| 163 | </tr>
|
| 164 | <tr>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 165 | <td><code>exclclassloader</code></td>
|
Marc R. Hoffmann | 2a6b5bf | 2009-08-11 12:54:36 +0000 | [diff] [blame] | 166 | <td>A list of class loader names, that should be excluded from execution
|
| 167 | analysis. The list entries are separated by a vertical bar
|
| 168 | (<code>|</code>) and may use wildcard characters (<code>*</code> and
|
| 169 | <code>?</code>). This option might be required in case of special
|
Marc R. Hoffmann | 57f9ab4 | 2009-08-24 10:52:42 +0000 | [diff] [blame] | 170 | frameworks that conflict with JaCoCo code instrumentation, in
|
| 171 | particular class loaders that do not have access to the Java runtime
|
| 172 | classes.
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 173 | </td>
|
| 174 | <td><code>sun.reflect.DelegatingClassLoader</code></td>
|
| 175 | </tr>
|
Brock Janiczak | f2d6f88 | 2010-05-04 06:47:40 +0000 | [diff] [blame] | 176 | <tr>
|
Marc R. Hoffmann | adfa118 | 2010-05-05 12:59:42 +0000 | [diff] [blame] | 177 | <td><code>sessionid</code></td>
|
| 178 | <td>A session identifier that is written with the execution data. Without
|
| 179 | this parameter a random identifier is created by the agent.
|
| 180 | </td>
|
| 181 | <td><i>auto-generated</i></td>
|
| 182 | </tr>
|
| 183 | <tr>
|
Brock Janiczak | f2d6f88 | 2010-05-04 06:47:40 +0000 | [diff] [blame] | 184 | <td><code>dumponexit</code></td>
|
Marc R. Hoffmann | adfa118 | 2010-05-05 12:59:42 +0000 | [diff] [blame] | 185 | <td>If set to <code>true</code> coverage data will be written on VM
|
| 186 | shutdown.
|
| 187 | </td>
|
Brock Janiczak | f2d6f88 | 2010-05-04 06:47:40 +0000 | [diff] [blame] | 188 | <td><code>true</code></td>
|
| 189 | </tr>
|
Marc R. Hoffmann | 4c3512a | 2010-05-12 08:50:23 +0000 | [diff] [blame^] | 190 | <tr>
|
| 191 | <td><code>output</code></td>
|
| 192 | <td>Output method to use for writing coverage data. Valid options are:
|
| 193 | <ul>
|
| 194 | <li><code>file</code>: At VM termination execution data is written to
|
| 195 | the file specified in the <code>tofile</code> attribute.</li>
|
| 196 | <li><code>tcpserver</code>: The agent listens for incoming connections
|
| 197 | on the TCP port specified by the <code>address</code> and
|
| 198 | <code>port</code> attribute. Execution data is written to this
|
| 199 | TCP connection.</li>
|
| 200 | <li><code>tcpclient</code>: At startup the agent connects to the TCP
|
| 201 | port specified by the <code>address</code> and <code>port</code>
|
| 202 | attribute. Execution data is written to this TCP connection.</li>
|
| 203 | </ul>
|
| 204 | </td>
|
| 205 | <td><code>file</code></td>
|
| 206 | </tr>
|
| 207 | <tr>
|
| 208 | <td><code>address</code></td>
|
| 209 | <td>IP address or hostname to bind to when the output method is
|
| 210 | <code>tcpserver</code> or connect to when the output method is
|
| 211 | <code>tcpclient</code>.
|
| 212 | </td>
|
| 213 | <td><code>localhost</code></td>
|
| 214 | </tr>
|
| 215 | <tr>
|
| 216 | <td><code>port</code></td>
|
| 217 | <td>Port to bind to when the output method is <code>tcpserver</code> or
|
| 218 | connect to when the output method is <code>tcpclient</code>. In
|
| 219 | <code>tcpserver</code> mode the port must be available, which means
|
| 220 | that if multiple JaCoCo agents should run on the same machine,
|
| 221 | different ports have to be specified.
|
| 222 | </td>
|
| 223 | <td><code>6300</code></td>
|
| 224 | </tr>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 225 | </tbody>
|
| 226 | </table>
|
| 227 |
|
| 228 |
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 229 | <h2><a name="agent">Task <code>agent</code></a></h2>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 230 |
|
Marc R. Hoffmann | d519add | 2009-08-11 11:09:29 +0000 | [diff] [blame] | 231 | <p>
|
| 232 | If the <code>coverage</code> task is not suitable for your launch target, you
|
| 233 | might alternatively use the <code>agent</code> task to create the Java agent
|
| 234 | parameter. The following example defines a Ant property with the name
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 235 | <code>agentvmparam</code> that can be directly used as a Java VM parameter:
|
Marc R. Hoffmann | d519add | 2009-08-11 11:09:29 +0000 | [diff] [blame] | 236 | </p>
|
| 237 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 238 | <pre class="source lang-xml">
|
Marc R. Hoffmann | d519add | 2009-08-11 11:09:29 +0000 | [diff] [blame] | 239 | <span class="nr"> 1</span><jacoco:agent property="agentvmparam"/>
|
| 240 | </pre>
|
| 241 |
|
| 242 | <p>
|
| 243 | This task has the same attributes as the <code>coverage</code> task plus an
|
| 244 | additional property to specify the target property name:
|
| 245 | </p>
|
| 246 |
|
| 247 | <table class="coverage">
|
| 248 | <thead>
|
| 249 | <tr>
|
| 250 | <td>Attribute</td>
|
| 251 | <td>Description</td>
|
| 252 | <td>Default</td>
|
| 253 | </tr>
|
| 254 | </thead>
|
| 255 | <tbody>
|
| 256 | <tr>
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 257 | <td><code>enabled</code></td>
|
| 258 | <td>When this variable is set to <code>false</code> the value of <code>property</code> will be set to an empty string, effectively
|
Marc R. Hoffmann | e3ef2f3 | 2010-01-28 18:17:46 +0000 | [diff] [blame] | 259 | disabling coverage instrumentation for any tasks that used the value.</td>
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 260 | <td><code>true</code></td>
|
| 261 | </tr>
|
| 262 | <tr>
|
Marc R. Hoffmann | d519add | 2009-08-11 11:09:29 +0000 | [diff] [blame] | 263 | <td><code>property</code></td>
|
| 264 | <td>Name of the Ant property to set.</td>
|
| 265 | <td><i>none (required)</i></td>
|
| 266 | </tr>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 267 | <tr>
|
| 268 | <td colspan="3"><i>All attributes of the <code>coverage</code> task.</i></td>
|
| 269 | </tr>
|
Marc R. Hoffmann | d519add | 2009-08-11 11:09:29 +0000 | [diff] [blame] | 270 | </tbody>
|
| 271 | </table>
|
| 272 |
|
Brock Janiczak | 74c1659 | 2010-01-29 21:34:14 +0000 | [diff] [blame] | 273 |
|
| 274 | <h2><a name="merge">Task <code>merge</code></a></h2>
|
| 275 |
|
| 276 | <p>
|
| 277 | This task can be used to merge the execution data from multiple test runs
|
| 278 | into a single data store.
|
| 279 | </p>
|
| 280 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 281 | <pre class="source lang-xml">
|
Marc R. Hoffmann | 5c8a703 | 2010-02-25 11:15:54 +0000 | [diff] [blame] | 282 | <span class="nr"> 1</span><jacoco:merge destfile="merged.exec">
|
| 283 | <span class="nr"> 2</span> <fileset dir="executionData" includes="*.exec"/>
|
| 284 | <span class="nr"> 3</span></jacoco:merge>
|
Brock Janiczak | 74c1659 | 2010-01-29 21:34:14 +0000 | [diff] [blame] | 285 | </pre>
|
| 286 |
|
| 287 | <p>
|
| 288 | The task definition can contain any number of resource collection types and
|
| 289 | has the following mandatory attribute:
|
| 290 | </p>
|
| 291 |
|
| 292 | <table class="coverage">
|
| 293 | <thead>
|
| 294 | <tr>
|
| 295 | <td>Attribute</td>
|
| 296 | <td>Description</td>
|
| 297 | <td>Default</td>
|
| 298 | </tr>
|
| 299 | </thead>
|
| 300 | <tbody>
|
| 301 | <tr>
|
| 302 | <td><code>destfile</code></td>
|
| 303 | <td>Location to write the merged execution data.</td>
|
| 304 | <td><i>none (required)</i></td>
|
| 305 | </tr>
|
| 306 | </tbody>
|
| 307 | </table>
|
| 308 |
|
| 309 |
|
Brock Janiczak | d267c57 | 2010-01-28 09:53:54 +0000 | [diff] [blame] | 310 | <h2><a name="report">Task <code>report</code></a></h2>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 311 |
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 312 | <p>
|
| 313 | Finally different reports can be created with the <code>report</code> task.
|
| 314 | A report task declaration consists of different sections, two specify the
|
| 315 | input data, additional ones specify the output formats:
|
| 316 | </p>
|
| 317 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 318 | <pre class="source lang-xml">
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 319 | <span class="nr"> 1</span><jacoco:report>
|
| 320 | <span class="nr"> 2</span>
|
| 321 | <span class="nr"> 3</span> <executiondata>
|
| 322 | <span class="nr"> 4</span> <file file="jacoco.exec"/>
|
| 323 | <span class="nr"> 5</span> </executiondata>
|
| 324 | <span class="nr"> 6</span>
|
| 325 | <span class="nr"> 7</span> <structure name="Example Project">
|
| 326 | <span class="nr"> 8</span> <classfiles>
|
| 327 | <span class="nr"> 9</span> <fileset dir="bin"/>
|
| 328 | <span class="nr"> 10</span> </classfiles>
|
| 329 | <span class="nr"> 11</span> <sourcefiles encoding="UTF-8">
|
| 330 | <span class="nr"> 12</span> <fileset dir="src"/>
|
| 331 | <span class="nr"> 13</span> </sourcefiles>
|
| 332 | <span class="nr"> 14</span> </structure>
|
| 333 | <span class="nr"> 15</span>
|
| 334 | <span class="nr"> 16</span> <html destdir="report"/>
|
| 335 | <span class="nr"> 17</span>
|
| 336 | <span class="nr"> 18</span></jacoco:report>
|
| 337 | </pre>
|
| 338 |
|
| 339 | <p>
|
| 340 | As you can see from the example above the <code>report</code> task is based
|
| 341 | on several nested elements:
|
| 342 | </p>
|
| 343 |
|
| 344 | <h3>Element <code>executiondata</code></h3>
|
| 345 |
|
| 346 | <p>
|
| 347 | Within this element Ant resources and resource collections can be specified,
|
| 348 | that represent JaCoCo execution data files. If more than one execution data
|
| 349 | file is specified, execution data is combined. A particular piece of code is
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 350 | considered executed when it is marked as such in any of the input files.
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 351 | </p>
|
| 352 |
|
| 353 | <h3>Element <code>structure</code></h3>
|
| 354 |
|
| 355 | <p>
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 356 | This element defines the report structure. It might contain the following
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 357 | nested elements:
|
| 358 | </p>
|
| 359 |
|
| 360 | <ul>
|
| 361 | <li><code>classfiles</code>: Container element for Ant resources and resource
|
Marc R. Hoffmann | ff7cd3a | 2010-04-06 08:54:29 +0000 | [diff] [blame] | 362 | collections that can specify Java class files, ZIP archive files (jar, war,
|
| 363 | ear etc.) or folders containing class files. Archives and folders are
|
| 364 | searched recursively for class files.</li>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 365 | <li><code>sourcefiles</code>: Optional container element for Ant resources and
|
| 366 | resource collections that specify corresponding source files. The element
|
| 367 | has an optional attribute <code>encoding</code> to specify the character
|
| 368 | encoding of the source files. If no encoding is given, the platform default
|
| 369 | is used. If source files are specified, some report formats include
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 370 | highlighted source code.</li>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 371 | </ul>
|
| 372 |
|
| 373 | <p>
|
| 374 | The structure can be refined with a hierarchy of <code>group</code> elements.
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 375 | This way the coverage report can reflect different modules of a software
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 376 | project. For each group element the corresponding class and source files can
|
Radek Liba | ad5fbc9 | 2009-10-26 13:26:53 +0000 | [diff] [blame] | 377 | be specified separately. For example, the build script of JaCoCo itself
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 378 | contains the following declaration to separate the different bundles in the
|
| 379 | report (see the <a href="../coverage/index.html">resulting report</a>):
|
| 380 | </p>
|
| 381 |
|
Marc R. Hoffmann | a760f32 | 2010-03-10 22:23:52 +0000 | [diff] [blame] | 382 | <pre class="source lang-xml">
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 383 | <span class="nr"> 1</span><structure name="JaCoCo">
|
| 384 | <span class="nr"> 2</span> <group name="org.jacoco.core">
|
| 385 | <span class="nr"> 3</span> <classfiles>
|
| 386 | <span class="nr"> 4</span> <path refid="bundle-org.jacoco.core"/>
|
| 387 | <span class="nr"> 5</span> </classfiles>
|
| 388 | <span class="nr"> 6</span> <sourcefiles>
|
| 389 | <span class="nr"> 7</span> <fileset dir="${workspace.dir}/org.jacoco.core/src"/>
|
| 390 | <span class="nr"> 8</span> </sourcefiles>
|
| 391 | <span class="nr"> 9</span> </group>
|
| 392 | <span class="nr"> 10</span> <group name="org.jacoco.report">
|
| 393 | <span class="nr"> 11</span> <classfiles>
|
| 394 | <span class="nr"> 12</span> <path refid="bundle-org.jacoco.report"/>
|
| 395 | <span class="nr"> 13</span> </classfiles>
|
| 396 | <span class="nr"> 14</span> <sourcefiles>
|
| 397 | <span class="nr"> 15</span> <fileset dir="${workspace.dir}/org.jacoco.report/src"/>
|
| 398 | <span class="nr"> 16</span> </sourcefiles>
|
| 399 | <span class="nr"> 17</span> </group>
|
| 400 | <span class="nr"> 18</span>
|
| 401 | <span class="nr"> 19</span> ...
|
| 402 | <span class="nr"> 20</span>
|
| 403 | <span class="nr"> 21</span></structure>
|
| 404 | </pre>
|
| 405 |
|
Marc R. Hoffmann | 722cad8 | 2010-03-09 18:22:33 +0000 | [diff] [blame] | 406 | <p>
|
| 407 | Both <code>structure</code> and <code>group</code> elements have the following
|
| 408 | mandatory attribute:
|
| 409 | </p>
|
| 410 |
|
| 411 | <table class="coverage">
|
| 412 | <thead>
|
| 413 | <tr>
|
| 414 | <td>Attribute</td>
|
| 415 | <td>Description</td>
|
| 416 | <td>Default</td>
|
| 417 | </tr>
|
| 418 | </thead>
|
| 419 | <tbody>
|
| 420 | <tr>
|
| 421 | <td><code>name</code></td>
|
| 422 | <td>Name of the structure or group.</td>
|
| 423 | <td><i>none (required)</i></td>
|
| 424 | </tr>
|
| 425 | </tbody>
|
| 426 | </table>
|
| 427 |
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 428 | <h3>Element <code>html</code></h3>
|
| 429 |
|
| 430 | <p>
|
Marc R. Hoffmann | 81f7920 | 2010-03-12 07:36:50 +0000 | [diff] [blame] | 431 | Create a multi-page report in HTML format. The report can either be written as
|
| 432 | multiple files into a directory or compressed into a single ZIP file.
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 433 | </p>
|
| 434 |
|
| 435 | <table class="coverage">
|
| 436 | <thead>
|
| 437 | <tr>
|
| 438 | <td>Attribute</td>
|
| 439 | <td>Description</td>
|
| 440 | <td>Default</td>
|
| 441 | </tr>
|
| 442 | </thead>
|
| 443 | <tbody>
|
| 444 | <tr>
|
| 445 | <td><code>destdir</code></td>
|
Marc R. Hoffmann | 81f7920 | 2010-03-12 07:36:50 +0000 | [diff] [blame] | 446 | <td>Directory to create the report in. Either this property or
|
| 447 | <code>destfile</code> has to be supplied.</td>
|
| 448 | <td><i>none (required)</i></td>
|
| 449 | </tr>
|
| 450 | <tr>
|
| 451 | <td><code>destfile</code></td>
|
| 452 | <td>Zip file to create the report in. Either this property or
|
| 453 | <code>destdir</code> has to be supplied.</td>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 454 | <td><i>none (required)</i></td>
|
| 455 | </tr>
|
Marc R. Hoffmann | 2ecbea5 | 2009-09-03 14:19:11 +0000 | [diff] [blame] | 456 | <tr>
|
| 457 | <td><code>footer</code></td>
|
| 458 | <td>Footer text for each report page.</td>
|
| 459 | <td><i>No footer</i></td>
|
| 460 | </tr>
|
Marc R. Hoffmann | 2becd33 | 2009-10-07 16:13:17 +0000 | [diff] [blame] | 461 | <tr>
|
| 462 | <td><code>encoding</code></td>
|
| 463 | <td>Encoding of the generated HTML pages.</td>
|
| 464 | <td><code>UTF-8</code></td>
|
| 465 | </tr>
|
| 466 | </tbody>
|
| 467 | </table>
|
| 468 |
|
| 469 | <h3>Element <code>xml</code></h3>
|
| 470 |
|
| 471 | <p>
|
| 472 | Create a single-file report in XML format.
|
| 473 | </p>
|
| 474 |
|
| 475 | <table class="coverage">
|
| 476 | <thead>
|
| 477 | <tr>
|
| 478 | <td>Attribute</td>
|
| 479 | <td>Description</td>
|
| 480 | <td>Default</td>
|
| 481 | </tr>
|
| 482 | </thead>
|
| 483 | <tbody>
|
| 484 | <tr>
|
Marc R. Hoffmann | 88b3f2f | 2009-10-19 16:10:35 +0000 | [diff] [blame] | 485 | <td><code>destfile</code></td>
|
| 486 | <td>Location to write the report file to.</td>
|
Marc R. Hoffmann | 2becd33 | 2009-10-07 16:13:17 +0000 | [diff] [blame] | 487 | <td><i>none (required)</i></td>
|
| 488 | </tr>
|
| 489 | <tr>
|
| 490 | <td><code>encoding</code></td>
|
| 491 | <td>Encoding of the generated XML document.</td>
|
| 492 | <td><code>UTF-8</code></td>
|
| 493 | </tr>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 494 | </tbody>
|
| 495 | </table>
|
| 496 |
|
| 497 | <h3>Element <code>csv</code></h3>
|
| 498 |
|
| 499 | <p>
|
Marc R. Hoffmann | 2becd33 | 2009-10-07 16:13:17 +0000 | [diff] [blame] | 500 | Create single-file report in CSV format.
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 501 | </p>
|
| 502 |
|
| 503 | <table class="coverage">
|
| 504 | <thead>
|
| 505 | <tr>
|
| 506 | <td>Attribute</td>
|
| 507 | <td>Description</td>
|
| 508 | <td>Default</td>
|
| 509 | </tr>
|
| 510 | </thead>
|
| 511 | <tbody>
|
| 512 | <tr>
|
Marc R. Hoffmann | 88b3f2f | 2009-10-19 16:10:35 +0000 | [diff] [blame] | 513 | <td><code>destfile</code></td>
|
| 514 | <td>Location to write the report file to.</td>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 515 | <td><i>none (required)</i></td>
|
| 516 | </tr>
|
Marc R. Hoffmann | e17fd11 | 2009-10-19 15:27:04 +0000 | [diff] [blame] | 517 | <tr>
|
| 518 | <td><code>encoding</code></td>
|
| 519 | <td>Encoding of the generated CSV document.</td>
|
| 520 | <td><code>UTF-8</code></td>
|
| 521 | </tr>
|
Marc R. Hoffmann | 2bb6fca | 2009-08-13 14:04:21 +0000 | [diff] [blame] | 522 | </tbody>
|
| 523 | </table>
|
| 524 |
|
Marc R. Hoffmann | 17be269 | 2010-02-02 05:44:47 +0000 | [diff] [blame] | 525 | </div>
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 526 | <div class="footer">
|
Marc R. Hoffmann | b623ffb | 2010-05-06 19:48:08 +0000 | [diff] [blame] | 527 | <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
|
Marc R. Hoffmann | df6ff96 | 2010-04-09 15:31:22 +0000 | [diff] [blame] | 528 | <a href="license.html">Copyright</a> © @copyright.years@ Mountainminds GmbH & Co. KG and Contributors
|
Marc R. Hoffmann | f7d1752 | 2009-08-07 11:21:23 +0000 | [diff] [blame] | 529 | </div>
|
| 530 |
|
| 531 | </body>
|
| 532 | </html> |