blob: ce40488bdc40a4f6d7fca791897c1b73a59e370c [file] [log] [blame]
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +00001<?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. Hoffmanna760f322010-03-10 22:23:52 +00007 <link rel="stylesheet" href="../coverage/.resources/prettify.css" charset="ISO-8859-1" type="text/css" />
Marc R. Hoffmannd7d2f752010-05-06 21:12:31 +00008 <link rel="shortcut icon" href=".resources/report.gif" type="image/gif" />
Marc R. Hoffmanna760f322010-03-10 22:23:52 +00009 <script type="text/javascript" src="../coverage/.resources/prettify.js"></script>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000010 <title>JaCoCo - Ant Tasks</title>
11</head>
Marc R. Hoffmanna760f322010-03-10 22:23:52 +000012<body onload="prettyPrint()">
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000013
14<div class="breadcrumb">
Marc R. Hoffmannd7d2f752010-05-06 21:12:31 +000015 <a href="../index.html" class="el_report">JaCoCo</a> &gt;
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000016 <a href="index.html" class="el_group">Documentation</a> &gt;
17 <span class="el_source">Ant Tasks</span>
18</div>
Marc R. Hoffmann17be2692010-02-02 05:44:47 +000019<div id="content">
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000020
21<h1>Ant Tasks</h1>
22
23<p>
24 JaCoCo comes with Ant tasks to launch Java programs with execution recording
Marc R. Hoffmann6fd10ff2010-06-02 21:42:25 +000025 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. Hoffmannc5d6e802010-07-02 19:34:16 +000034<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. Hoffmann6fd10ff2010-06-02 21:42:25 +000040<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. Hoffmannb8a77462009-08-21 14:53:50 +000055</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. Hoffmann57f9ab42009-08-24 10:52:42 +000063<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. Hoffmannf7d17522009-08-07 11:21:23 +000066</p>
67
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +000068<pre class="source lang-xml linenums">
69&lt;project name="Example" xmlns:jacoco="antlib:org.jacoco.ant"&gt;
70
71 &lt;taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"&gt;
72 &lt;classpath path="<i>path_to_jacoco</i>/lib/jacocoant.jar"/&gt;
73 &lt;/taskdef&gt;
74
75 ...
76
77&lt;/project&gt;
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000078</pre>
79
80<p>
Marc R. Hoffmanndb3e7d02009-08-12 10:57:39 +000081 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. Hoffmann6fd10ff2010-06-02 21:42:25 +000084 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. Hoffmannf7d17522009-08-07 11:21:23 +000087 <code>jacoco</code> prefix declared above.
88</p>
89
Brock Janiczakd267c572010-01-28 09:53:54 +000090<h2><a name="coverage">Task <code>coverage</code></a></h2>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000091
92<p>
Evgeny Mandrikov71b5f6e2011-02-19 22:55:47 +000093 The standard Ant tasks to launch Java programs are <code>java</code>, <code>junit</code> and
94 <code>testng</code>. To add code coverage recording to these tasks they can
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +000095 simply be wrapped with the <code>coverage</code> task as shown in the
96 following examples:
97</p>
98
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +000099<pre class="source lang-xml linenums">
100&lt;jacoco:coverage>
101 &lt;java classname="org.jacoco.examples.HelloJaCoCo" fork="true"&gt;
102 &lt;classpath&gt;
103 &lt;pathelement location="./bin"/&gt;
104 &lt;/classpath&gt;
105 &lt;/java&gt;
106&lt;/jacoco:coverage&gt;
107
108
109&lt;jacoco:coverage>
110 &lt;junit fork="true" forkmode="once"&gt;
111 &lt;test name="org.jacoco.examples.HelloJaCoCoTest"/&gt;
112 &lt;classpath&gt;
113 &lt;pathelement location="./bin"/&gt;
114 &lt;/classpath&gt;
115 &lt;/junit&gt;
116&lt;/jacoco:coverage&gt;
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000117</pre>
118
119<p>
Radek Libaad5fbc92009-10-26 13:26:53 +0000120 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. Hoffmannf7d17522009-08-07 11:21:23 +0000123</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 Janiczakd267c572010-01-28 09:53:54 +0000149 <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. Hoffmanne3ef2f32010-01-28 18:17:46 +0000153 <tr>
Brock Janiczak003d47c2010-01-15 00:45:17 +0000154 <td><code>destfile</code></td>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000155 <td>Path to the output file for execution data.</td>
156 <td><code>jacoco.exec</code></td>
157 </tr>
158 <tr>
Brock Janiczak003d47c2010-01-15 00:45:17 +0000159 <td><code>append</code></td>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000160 <td>If set to <code>true</code> and the execution data file already
Brock Janiczak003d47c2010-01-15 00:45:17 +0000161 exists, coverage data is appended to the existing file. If set to
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000162 <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. Hoffmanncf5345f2009-09-10 15:01:24 +0000167 <td><code>includes</code></td>
Radek Libaad5fbc92009-10-26 13:26:53 +0000168 <td>A list of class names that should be included in execution analysis.
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +0000169 The list entries are separated by a colon (<code>:</code>) and
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +0000170 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.
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +0000179 The list entries are separated by a colon (<code>:</code>) and
Marc R. Hoffmanncf5345f2009-09-10 15:01:24 +0000180 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. Hoffmannf7d17522009-08-07 11:21:23 +0000187 <td><code>exclclassloader</code></td>
Marc R. Hoffmann2a6b5bf2009-08-11 12:54:36 +0000188 <td>A list of class loader names, that should be excluded from execution
Evgeny Mandrikovbab5da42011-02-20 21:43:33 +0000189 analysis. The list entries are separated by a colon
190 (<code>:</code>) and may use wildcard characters (<code>*</code> and
Marc R. Hoffmann2a6b5bf2009-08-11 12:54:36 +0000191 <code>?</code>). This option might be required in case of special
Marc R. Hoffmann57f9ab42009-08-24 10:52:42 +0000192 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. Hoffmannf7d17522009-08-07 11:21:23 +0000195 </td>
196 <td><code>sun.reflect.DelegatingClassLoader</code></td>
197 </tr>
Brock Janiczakf2d6f882010-05-04 06:47:40 +0000198 <tr>
Marc R. Hoffmannadfa1182010-05-05 12:59:42 +0000199 <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 Janiczakf2d6f882010-05-04 06:47:40 +0000206 <td><code>dumponexit</code></td>
Marc R. Hoffmannadfa1182010-05-05 12:59:42 +0000207 <td>If set to <code>true</code> coverage data will be written on VM
208 shutdown.
209 </td>
Brock Janiczakf2d6f882010-05-04 06:47:40 +0000210 <td><code>true</code></td>
211 </tr>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000212 <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>
Marc R. Hoffmannc0658682011-06-20 06:01:37 +0000225 <li><code>mbean</code>: The agent registers an JMX MBean under the
226 name <code>org.jacoco:type=Runtime</code>.</li>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000227 </ul>
228 </td>
229 <td><code>file</code></td>
230 </tr>
231 <tr>
232 <td><code>address</code></td>
233 <td>IP address or hostname to bind to when the output method is
234 <code>tcpserver</code> or connect to when the output method is
Marc R. Hoffmann1cf157a2010-06-04 05:54:48 +0000235 <code>tcpclient</code>. In <code>tcpserver</code> mode the value
236 "<code>*</code>" causes the agent to accept connections on any local
237 address.
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000238 </td>
Marc R. Hoffmann1cf157a2010-06-04 05:54:48 +0000239 <td><i>loopback interface</i></td>
Marc R. Hoffmann4c3512a2010-05-12 08:50:23 +0000240 </tr>
241 <tr>
242 <td><code>port</code></td>
243 <td>Port to bind to when the output method is <code>tcpserver</code> or
244 connect to when the output method is <code>tcpclient</code>. In
245 <code>tcpserver</code> mode the port must be available, which means
246 that if multiple JaCoCo agents should run on the same machine,
247 different ports have to be specified.
248 </td>
249 <td><code>6300</code></td>
250 </tr>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000251 </tbody>
252</table>
253
254
Brock Janiczakd267c572010-01-28 09:53:54 +0000255<h2><a name="agent">Task <code>agent</code></a></h2>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000256
Marc R. Hoffmannd519add2009-08-11 11:09:29 +0000257<p>
258 If the <code>coverage</code> task is not suitable for your launch target, you
Marc R. Hoffmann6fd10ff2010-06-02 21:42:25 +0000259 might alternatively use the <code>agent</code> task to create the
260 <a href="agent.html">Java agent</a> parameter. The following example defines a
261 Ant property with the name <code>agentvmparam</code> that can be directly used
262 as a Java VM parameter:
Marc R. Hoffmannd519add2009-08-11 11:09:29 +0000263</p>
264
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000265<pre class="source lang-xml linenums">
266&lt;jacoco:agent property="agentvmparam"/&gt;
Marc R. Hoffmannd519add2009-08-11 11:09:29 +0000267</pre>
268
269<p>
270 This task has the same attributes as the <code>coverage</code> task plus an
271 additional property to specify the target property name:
272</p>
273
274<table class="coverage">
275 <thead>
276 <tr>
277 <td>Attribute</td>
278 <td>Description</td>
279 <td>Default</td>
280 </tr>
281 </thead>
282 <tbody>
283 <tr>
Brock Janiczakd267c572010-01-28 09:53:54 +0000284 <td><code>enabled</code></td>
285 <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. Hoffmanne3ef2f32010-01-28 18:17:46 +0000286 disabling coverage instrumentation for any tasks that used the value.</td>
Brock Janiczakd267c572010-01-28 09:53:54 +0000287 <td><code>true</code></td>
288 </tr>
289 <tr>
Marc R. Hoffmannd519add2009-08-11 11:09:29 +0000290 <td><code>property</code></td>
291 <td>Name of the Ant property to set.</td>
292 <td><i>none (required)</i></td>
293 </tr>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000294 <tr>
295 <td colspan="3"><i>All attributes of the <code>coverage</code> task.</i></td>
296 </tr>
Marc R. Hoffmannd519add2009-08-11 11:09:29 +0000297 </tbody>
298</table>
299
Brock Janiczak74c16592010-01-29 21:34:14 +0000300
Marc R. Hoffmann7c775162010-05-27 16:43:34 +0000301<h2><a name="dump">Task <code>dump</code></a></h2>
302
303<p>
304 This task allows to remotely collect execution data from another JVM without
305 stopping it. For example:
306</p>
307
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000308<pre class="source lang-xml linenums">
309&lt;jacoco:dump address="server.example.com" reset="true" destfile="remote.exec"/&gt;
Marc R. Hoffmann7c775162010-05-27 16:43:34 +0000310</pre>
311
312<p>
313 Remote dumps are usefull for long running Java processes like application
314 servers.
315</p>
316
317<p class="hint">
Marc R. Hoffmann6fd10ff2010-06-02 21:42:25 +0000318 The target JVM needs to have a <a href="agent.html">JaCoCo agent</a>
319 configured with <code>output</code> mode <code>tcpserver</code>. See
Marc R. Hoffmann7c775162010-05-27 16:43:34 +0000320 <a href="#coverage"><code>coverage</code></a> and
321 <a href="#agent"><code>agent</code></a> tasks above.
322</p>
323
324<p>
325 The <code>dump</code> task has the following attributes:
326</p>
327
328<table class="coverage">
329 <thead>
330 <tr>
331 <td>Attribute</td>
332 <td>Description</td>
333 <td>Default</td>
334 </tr>
335 </thead>
336 <tbody>
337 <tr>
338 <td><code>address</code></td>
339 <td>Target IP address or DNS name.</td>
340 <td><code>localhost</code></td>
341 </tr>
342 <tr>
343 <td><code>port</code></td>
344 <td>Target TCP port.</td>
345 <td><code>6300</code></td>
346 </tr>
347 <tr>
348 <td><code>dump</code></td>
349 <td>Flag whether execution data should be dumped.</td>
350 <td><code>true</code></td>
351 </tr>
352 <tr>
353 <td><code>reset</code></td>
354 <td>Flag whether execution data should be reset in the target agent after
355 the dump.</td>
356 <td><code>false</code></td>
357 </tr>
358 <tr>
359 <td><code>destfile</code></td>
360 <td>File location to write the collected execution data to.</td>
361 <td><i>none (required if dump=true)</i></td>
362 </tr>
363 <tr>
364 <td><code>append</code></td>
365 <td>If set to <code>true</code> and the execution data file already
366 exists, coverage data is appended to the existing file. If set to
367 <code>false</code>, an existing execution data file will be replaced.
368 </td>
369 <td><code>true</code></td>
370 </tr>
371 </tbody>
372</table>
373
374
Brock Janiczak74c16592010-01-29 21:34:14 +0000375<h2><a name="merge">Task <code>merge</code></a></h2>
376
377<p>
378 This task can be used to merge the execution data from multiple test runs
379 into a single data store.
380</p>
381
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000382<pre class="source lang-xml linenums">
383&lt;jacoco:merge destfile="merged.exec"&gt;
384 &lt;fileset dir="executionData" includes="*.exec"/&gt;
385&lt;/jacoco:merge&gt;
Brock Janiczak74c16592010-01-29 21:34:14 +0000386</pre>
387
388<p>
389 The task definition can contain any number of resource collection types and
390 has the following mandatory attribute:
391</p>
392
393<table class="coverage">
394 <thead>
395 <tr>
396 <td>Attribute</td>
397 <td>Description</td>
398 <td>Default</td>
399 </tr>
400 </thead>
401 <tbody>
402 <tr>
403 <td><code>destfile</code></td>
Marc R. Hoffmann7c775162010-05-27 16:43:34 +0000404 <td>File location to write the merged execution data to.</td>
Brock Janiczak74c16592010-01-29 21:34:14 +0000405 <td><i>none (required)</i></td>
406 </tr>
407 </tbody>
408</table>
409
410
Brock Janiczakd267c572010-01-28 09:53:54 +0000411<h2><a name="report">Task <code>report</code></a></h2>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000412
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000413<p>
414 Finally different reports can be created with the <code>report</code> task.
415 A report task declaration consists of different sections, two specify the
416 input data, additional ones specify the output formats:
417</p>
418
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000419<pre class="source lang-xml linenums">
420&lt;jacoco:report&gt;
421
422 &lt;executiondata&gt;
423 &lt;file file="jacoco.exec"/&gt;
424 &lt;/executiondata&gt;
425
426 &lt;structure name="Example Project"&gt;
427 &lt;classfiles&gt;
428 &lt;fileset dir="classes"/&gt;
429 &lt;/classfiles&gt;
430 &lt;sourcefiles encoding="UTF-8"&gt;
431 &lt;fileset dir="src"/&gt;
432 &lt;/sourcefiles&gt;
433 &lt;/structure&gt;
434
435 &lt;html destdir="report"/&gt;
436
437&lt;/jacoco:report&gt;
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000438</pre>
439
440<p>
441 As you can see from the example above the <code>report</code> task is based
442 on several nested elements:
443</p>
444
445<h3>Element <code>executiondata</code></h3>
446
447<p>
448 Within this element Ant resources and resource collections can be specified,
449 that represent JaCoCo execution data files. If more than one execution data
450 file is specified, execution data is combined. A particular piece of code is
Radek Libaad5fbc92009-10-26 13:26:53 +0000451 considered executed when it is marked as such in any of the input files.
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000452</p>
453
454<h3>Element <code>structure</code></h3>
455
456<p>
Radek Libaad5fbc92009-10-26 13:26:53 +0000457 This element defines the report structure. It might contain the following
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000458 nested elements:
459</p>
460
461<ul>
462 <li><code>classfiles</code>: Container element for Ant resources and resource
Marc R. Hoffmannff7cd3a2010-04-06 08:54:29 +0000463 collections that can specify Java class files, ZIP archive files (jar, war,
464 ear etc.) or folders containing class files. Archives and folders are
465 searched recursively for class files.</li>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000466 <li><code>sourcefiles</code>: Optional container element for Ant resources and
Marc R. Hoffmann5625ff62011-03-27 12:53:52 +0000467 resource collections that specify corresponding source files. If source
468 files are specified, some report formats include highlighted source code.</li>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000469</ul>
470
471<p>
Marc R. Hoffmann5625ff62011-03-27 12:53:52 +0000472 The <code>sourcefiles</code> element has these optional attributes:
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>
485 <td><code>encoding</code></td>
486 <td>Character encoding of the source files.</td>
487 <td>Platform default encoding</td>
488 </tr>
489 <tr>
490 <td><code>tabwidth</code></td>
491 <td>Number of whitespace characters that represent a tab character.</td>
492 <td>4 characters</td>
493 </tr>
494 </tbody>
495</table>
496
497<p>
Marc R. Hoffmann1f01f862011-01-12 21:58:34 +0000498 Note that the <code>classfiles</code> and <code>sourcefiles</code> elements
499 accept any
500 <a href="http://ant.apache.org/manual/Types/resources.html#collection">Ant
501 resource collection</a>. Therefore also filtering the class file set is
502 possible and allows to narrow the scope of the report, for example:
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000503</p>
504
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000505<pre class="source lang-xml linenums">
506&lt;classfiles&gt;
507 &lt;fileset dir="classes"&gt;
508 &lt;include name="org/jacoco/examples/important/**/*.class"/&gt;
509 &lt;/fileset&gt;
510&lt;/classfiles&gt;
Marc R. Hoffmann1f01f862011-01-12 21:58:34 +0000511</pre>
512
Marc R. Hoffmann7232b742011-03-07 21:54:08 +0000513<p class="hint">
514 <b>Performance Warning:</b> Although it is technically possible and sometimes
515 convenient to use Ant's <code>zipfileset</code> to specify class or source
516 files, this resource type has poor performance characteristics and comes with
517 an huge memory overhead especially for large scale projects.
518</p>
519
Marc R. Hoffmann1f01f862011-01-12 21:58:34 +0000520<p>
521 The structure can be refined with a hierarchy of <code>group</code> elements.
522 This way the coverage report can reflect different modules of a software
523 project. For each group element the corresponding class and source files can
524 be specified separately. For example:
525</p>
526
Marc R. Hoffmann0fd9c832011-03-16 20:42:40 +0000527<pre class="source lang-xml linenums">
528&lt;structure name="Example Project"&gt;
529 &lt;group name="Server"&gt;
530 &lt;classfiles&gt;
531 &lt;fileset dir="${workspace.dir}/org.jacoco.example.server/classes"/&gt;
532 &lt;/classfiles&gt;
533 &lt;sourcefiles&gt;
534 &lt;fileset dir="${workspace.dir}/org.jacoco.example.server/src"/&gt;
535 &lt;/sourcefiles&gt;
536 &lt;/group&gt;
537 &lt;group name="Client"&gt;
538 &lt;classfiles&gt;
539 &lt;fileset dir="${workspace.dir}/org.jacoco.example.client/classes"/&gt;
540 &lt;/classfiles&gt;
541 &lt;sourcefiles&gt;
542 &lt;fileset dir="${workspace.dir}/org.jacoco.example.client/src"/&gt;
543 &lt;/sourcefiles&gt;
544 &lt;/group&gt;
545
546 ...
547
548&lt;/structure&gt;
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000549</pre>
550
Marc R. Hoffmann722cad82010-03-09 18:22:33 +0000551<p>
552 Both <code>structure</code> and <code>group</code> elements have the following
553 mandatory attribute:
554</p>
555
556<table class="coverage">
557 <thead>
558 <tr>
559 <td>Attribute</td>
560 <td>Description</td>
561 <td>Default</td>
562 </tr>
563 </thead>
564 <tbody>
565 <tr>
566 <td><code>name</code></td>
567 <td>Name of the structure or group.</td>
568 <td><i>none (required)</i></td>
569 </tr>
570 </tbody>
571</table>
572
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000573<h3>Element <code>html</code></h3>
574
575<p>
Marc R. Hoffmann81f79202010-03-12 07:36:50 +0000576 Create a multi-page report in HTML format. The report can either be written as
577 multiple files into a directory or compressed into a single ZIP file.
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000578</p>
579
580<table class="coverage">
581 <thead>
582 <tr>
583 <td>Attribute</td>
584 <td>Description</td>
585 <td>Default</td>
586 </tr>
587 </thead>
588 <tbody>
589 <tr>
590 <td><code>destdir</code></td>
Marc R. Hoffmann81f79202010-03-12 07:36:50 +0000591 <td>Directory to create the report in. Either this property or
592 <code>destfile</code> has to be supplied.</td>
593 <td><i>none (required)</i></td>
594 </tr>
595 <tr>
596 <td><code>destfile</code></td>
597 <td>Zip file to create the report in. Either this property or
598 <code>destdir</code> has to be supplied.</td>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000599 <td><i>none (required)</i></td>
600 </tr>
Marc R. Hoffmann2ecbea52009-09-03 14:19:11 +0000601 <tr>
602 <td><code>footer</code></td>
603 <td>Footer text for each report page.</td>
Marc R. Hoffmannae8c2a82010-10-05 16:20:10 +0000604 <td><i>no footer</i></td>
Marc R. Hoffmann2ecbea52009-09-03 14:19:11 +0000605 </tr>
Marc R. Hoffmann2becd332009-10-07 16:13:17 +0000606 <tr>
607 <td><code>encoding</code></td>
Marc R. Hoffmannae8c2a82010-10-05 16:20:10 +0000608 <td>Character encoding of generated HTML pages.</td>
Marc R. Hoffmann2becd332009-10-07 16:13:17 +0000609 <td><code>UTF-8</code></td>
610 </tr>
Marc R. Hoffmannae8c2a82010-10-05 16:20:10 +0000611 <tr>
612 <td><code>locale</code></td>
613 <td>Locale specified as ISO code (en, fr, jp, ...) used for number formating.</td>
614 <td><i>platform locale</i></td>
615 </tr>
Marc R. Hoffmann2becd332009-10-07 16:13:17 +0000616 </tbody>
617</table>
618
619<h3>Element <code>xml</code></h3>
620
621<p>
622 Create a single-file report in XML format.
623</p>
624
625<table class="coverage">
626 <thead>
627 <tr>
628 <td>Attribute</td>
629 <td>Description</td>
630 <td>Default</td>
631 </tr>
632 </thead>
633 <tbody>
634 <tr>
Marc R. Hoffmann88b3f2f2009-10-19 16:10:35 +0000635 <td><code>destfile</code></td>
636 <td>Location to write the report file to.</td>
Marc R. Hoffmann2becd332009-10-07 16:13:17 +0000637 <td><i>none (required)</i></td>
638 </tr>
639 <tr>
640 <td><code>encoding</code></td>
641 <td>Encoding of the generated XML document.</td>
642 <td><code>UTF-8</code></td>
643 </tr>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000644 </tbody>
645</table>
646
647<h3>Element <code>csv</code></h3>
648
649<p>
Marc R. Hoffmann2becd332009-10-07 16:13:17 +0000650 Create single-file report in CSV format.
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000651</p>
652
653<table class="coverage">
654 <thead>
655 <tr>
656 <td>Attribute</td>
657 <td>Description</td>
658 <td>Default</td>
659 </tr>
660 </thead>
661 <tbody>
662 <tr>
Marc R. Hoffmann88b3f2f2009-10-19 16:10:35 +0000663 <td><code>destfile</code></td>
664 <td>Location to write the report file to.</td>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000665 <td><i>none (required)</i></td>
666 </tr>
Marc R. Hoffmanne17fd112009-10-19 15:27:04 +0000667 <tr>
668 <td><code>encoding</code></td>
669 <td>Encoding of the generated CSV document.</td>
670 <td><code>UTF-8</code></td>
671 </tr>
Marc R. Hoffmann2bb6fca2009-08-13 14:04:21 +0000672 </tbody>
673</table>
674
Marc R. Hoffmann17be2692010-02-02 05:44:47 +0000675</div>
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000676<div class="footer">
Marc R. Hoffmannb623ffb2010-05-06 19:48:08 +0000677 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
Marc R. Hoffmanndf6ff962010-04-09 15:31:22 +0000678 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
Marc R. Hoffmannf7d17522009-08-07 11:21:23 +0000679</div>
680
681</body>
682</html>