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