blob: c0e84e4f7dc40bad7a1b4b7b0ab1c608263a23ca [file] [log] [blame]
Marc R. Hoffmanne571f3f2012-05-13 12:18:02 +00001<?xml version="1.0" encoding="UTF-8" ?>
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +00002<!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>
Marc R. Hoffmanne571f3f2012-05-13 12:18:02 +00005 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <link rel="stylesheet" href=".resources/doc.css" charset="UTF-8" type="text/css" />
7 <link rel="stylesheet" href="../coverage/.resources/prettify.css" charset="UTF-8" type="text/css" />
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +00008 <link rel="shortcut icon" href=".resources/report.gif" type="image/gif" />
9 <script type="text/javascript" src="../coverage/.resources/prettify.js"></script>
10 <title>JaCoCo - Ant Tasks</title>
11</head>
12<body onload="prettyPrint()">
13
14<div class="breadcrumb">
15 <a href="../index.html" class="el_report">JaCoCo</a> &gt;
16 <a href="index.html" class="el_group">Documentation</a> &gt;
17 <span class="el_source">Ant Tasks</span>
18</div>
19<div id="content">
20
21<h1>Ant Tasks</h1>
22
23<p>
24 JaCoCo comes with Ant tasks to launch Java programs with execution recording
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
Marc R. Hoffmann235a09e2012-12-23 15:57:16 +010031 creates with the <a href="#report"><code>report</code></a> task. For
32 <a href="offline.html">offline instrumentation</a> the task
33 <a href="#instrument"><code>instrument</code></a> can be used to prepare class
34 files.
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000035</p>
36
37<p class="hint">
38 If you want to have line number information included in the coverage reports
39 or you want source code highlighting the class files of the test target must
40 be compiled with debug information.
41</p>
42
43<h2>Example</h2>
44
45<p>
46 The JaCoCo distribution contains a simple example how code coverage can be
47 added to a Ant based build. The
Marc R. Hoffmanna3aa78b2012-05-02 18:56:47 +000048 <a href="examples/build/build.xml">build script</a> compiles Java sources,
Marc R. Hoffmann78309272012-05-02 19:25:44 +000049 runs an simple Java programm and creates a coverage report. The complete
50 example is located in the <code>./doc/examples/build</code> folder of the
51 distribution.
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000052</p>
53
54
55<h2>Prerequisites</h2>
56
57<p>
58 The JaCoCo Ant tasks require
59</p>
60
61<ul>
62 <li>Ant 1.7.0 or higher and</li>
63 <li>Java 1.5 or higher (for both, the Ant runner and the test executor).</li>
64</ul>
65
66
67<p>All tasks are defined in <code>jacocoant.jar</code> (which is part of the
68 distribution) and can be included in your Ant scripts with the usual
69 <code>taskdef</code> declaration:
70</p>
71
72<pre class="source lang-xml linenums">
73&lt;project name="Example" xmlns:jacoco="antlib:org.jacoco.ant"&gt;
74
75 &lt;taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"&gt;
76 &lt;classpath path="<i>path_to_jacoco</i>/lib/jacocoant.jar"/&gt;
77 &lt;/taskdef&gt;
78
79 ...
80
81&lt;/project&gt;
82</pre>
83
84<p>
85 Alternatively you might also place the <code>jacocoant.jar</code> in your
86 Ant <code><i>ANT_HOME</i>/lib</code> folder. If you use the name space URI
87 <code>antlib:org.jacoco.ant</code> for JaCoCo tasks Ant will find them
88 automatically without the <code>taskdef</code> declaration above.
89</p>
90
91<p class="hint">
92 Declaring a XML namespace for JaCoCo tasks is optional but always recommended
93 if you mix tasks from different libraries. All subsequent examples use the
94 <code>jacoco</code> prefix declared above. If you don't declare a separate
95 namespace the <code>jacoco</code> prefix must be removed from the following
96 examples.
97</p>
98
99<h2><a name="coverage">Task <code>coverage</code></a></h2>
100
101<p>
102 The standard Ant tasks to launch Java programs are <code>java</code>, <code>junit</code> and
103 <code>testng</code>. To add code coverage recording to these tasks they can
104 simply be wrapped with the <code>coverage</code> task as shown in the
105 following examples:
106</p>
107
108<pre class="source lang-xml linenums">
109&lt;jacoco:coverage>
110 &lt;java classname="org.jacoco.examples.HelloJaCoCo" fork="true"&gt;
111 &lt;classpath&gt;
112 &lt;pathelement location="./bin"/&gt;
113 &lt;/classpath&gt;
114 &lt;/java&gt;
115&lt;/jacoco:coverage&gt;
116
117
118&lt;jacoco:coverage>
119 &lt;junit fork="true" forkmode="once"&gt;
120 &lt;test name="org.jacoco.examples.HelloJaCoCoTest"/&gt;
121 &lt;classpath&gt;
122 &lt;pathelement location="./bin"/&gt;
123 &lt;/classpath&gt;
124 &lt;/junit&gt;
125&lt;/jacoco:coverage&gt;
126</pre>
127
128<p>
129 Resulting coverage information is collected during execution and written
130 to a file when the process terminates. Note the <code>fork</code> attribute
131 above in the wrapped <code>java</code> task.
132</p>
133
134<p class="hint">
135 The nested task always has to declare <code>fork="true"</code>, otherwise the
136 <code>coverage</code> task can't record coverage information and will fail.
137 In addition the <code>junit</code> task should declare
138 <code>forkmode="once"</code> to avoid starting a new JVM for every single test
139 case and decreasing execution performance dramatically (unless this is
140 required by the nature of the test cases).
141</p>
142
143<p>
144 The coverage task must wrap exactly one task. While it typically works without
145 any configuration, the behavior can be adjusted with some optional attributes:
146</p>
147
148<table class="coverage">
149 <thead>
150 <tr>
151 <td>Attribute</td>
152 <td>Description</td>
153 <td>Default</td>
154 </tr>
155 </thead>
156 <tbody>
157 <tr>
158 <td><code>enabled</code></td>
159 <td>If set to <code>true</code> coverage data will be collected for the contained task.</td>
160 <td><code>true</code></td>
161 </tr>
162 <tr>
163 <td><code>destfile</code></td>
164 <td>Path to the output file for execution data.</td>
165 <td><code>jacoco.exec</code></td>
166 </tr>
167 <tr>
168 <td><code>append</code></td>
169 <td>If set to <code>true</code> and the execution data file already
170 exists, coverage data is appended to the existing file. If set to
171 <code>false</code>, an existing execution data file will be replaced.
172 </td>
173 <td><code>true</code></td>
174 </tr>
175 <tr>
176 <td><code>includes</code></td>
177 <td>A list of class names that should be included in execution analysis.
178 The list entries are separated by a colon (<code>:</code>) and
179 may use wildcard characters (<code>*</code> and <code>?</code>).
180 Except for performance optimization or technical corner cases this
181 option is normally not required.
182 </td>
183 <td><code>*</code> (all classes)</td>
184 </tr>
185 <tr>
186 <td><code>excludes</code></td>
187 <td>A list of class names that should be excluded from execution analysis.
188 The list entries are separated by a colon (<code>:</code>) and
189 may use wildcard characters (<code>*</code> and <code>?</code>).
190 Except for performance optimization or technical corner cases this
191 option is normally not required.
192 </td>
193 <td><i>empty</i> (no excluded classes)</td>
194 </tr>
195 <tr>
196 <td><code>exclclassloader</code></td>
197 <td>A list of class loader names, that should be excluded from execution
198 analysis. The list entries are separated by a colon
199 (<code>:</code>) and may use wildcard characters (<code>*</code> and
200 <code>?</code>). This option might be required in case of special
201 frameworks that conflict with JaCoCo code instrumentation, in
202 particular class loaders that do not have access to the Java runtime
203 classes.
204 </td>
205 <td><code>sun.reflect.DelegatingClassLoader</code></td>
206 </tr>
207 <tr>
208 <td><code>sessionid</code></td>
209 <td>A session identifier that is written with the execution data. Without
210 this parameter a random identifier is created by the agent.
211 </td>
212 <td><i>auto-generated</i></td>
213 </tr>
214 <tr>
215 <td><code>dumponexit</code></td>
216 <td>If set to <code>true</code> coverage data will be written on VM
217 shutdown.
218 </td>
219 <td><code>true</code></td>
220 </tr>
221 <tr>
222 <td><code>output</code></td>
223 <td>Output method to use for writing coverage data. Valid options are:
224 <ul>
225 <li><code>file</code>: At VM termination execution data is written to
226 the file specified in the <code>destfile</code> attribute.</li>
227 <li><code>tcpserver</code>: The agent listens for incoming connections
228 on the TCP port specified by the <code>address</code> and
229 <code>port</code> attribute. Execution data is written to this
230 TCP connection.</li>
231 <li><code>tcpclient</code>: At startup the agent connects to the TCP
232 port specified by the <code>address</code> and <code>port</code>
233 attribute. Execution data is written to this TCP connection.</li>
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000234 </ul>
235 </td>
236 <td><code>file</code></td>
237 </tr>
238 <tr>
239 <td><code>address</code></td>
240 <td>IP address or hostname to bind to when the output method is
241 <code>tcpserver</code> or connect to when the output method is
242 <code>tcpclient</code>. In <code>tcpserver</code> mode the value
243 "<code>*</code>" causes the agent to accept connections on any local
244 address.
245 </td>
246 <td><i>loopback interface</i></td>
247 </tr>
248 <tr>
249 <td><code>port</code></td>
250 <td>Port to bind to when the output method is <code>tcpserver</code> or
251 connect to when the output method is <code>tcpclient</code>. In
252 <code>tcpserver</code> mode the port must be available, which means
253 that if multiple JaCoCo agents should run on the same machine,
254 different ports have to be specified.
255 </td>
256 <td><code>6300</code></td>
257 </tr>
Marc R. Hoffmanncf41fc12012-06-30 00:15:43 +0000258 <tr>
259 <td><code>classdumpdir</code></td>
260 <td>Location relative to the working directory where all class files seen
261 by the agent are dumped to. This can be useful for debugging purposes
262 or in case of dynamically created classes for example when scripting
263 engines are used.
264 </td>
265 <td><i>no dumps</i></td>
266 </tr>
Marc R. Hoffmanne2930e72013-01-08 21:18:35 +0100267 <tr>
268 <td><code>jmx</code></td>
269 <td>If set to <code>true</code> the agent exposes
270 <a href="./api/org/jacoco/agent/rt/IAgent.html">functionality</a> via
271 JMX under the name <code>org.jacoco:type=Runtime</code>.
272 </td>
273 <td><code>false</code></td>
274 </tr>
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000275 </tbody>
276</table>
277
278
279<h2><a name="agent">Task <code>agent</code></a></h2>
280
281<p>
282 If the <code>coverage</code> task is not suitable for your launch target, you
283 might alternatively use the <code>agent</code> task to create the
284 <a href="agent.html">Java agent</a> parameter. The following example defines a
285 Ant property with the name <code>agentvmparam</code> that can be directly used
286 as a Java VM parameter:
287</p>
288
289<pre class="source lang-xml linenums">
290&lt;jacoco:agent property="agentvmparam"/&gt;
291</pre>
292
293<p>
294 This task has the same attributes as the <code>coverage</code> task plus an
295 additional property to specify the target property name:
296</p>
297
298<table class="coverage">
299 <thead>
300 <tr>
301 <td>Attribute</td>
302 <td>Description</td>
303 <td>Default</td>
304 </tr>
305 </thead>
306 <tbody>
307 <tr>
308 <td><code>enabled</code></td>
309 <td>When this variable is set to <code>false</code> the value of <code>property</code> will be set to an empty string, effectively
310 disabling coverage instrumentation for any tasks that used the value.</td>
311 <td><code>true</code></td>
312 </tr>
313 <tr>
314 <td><code>property</code></td>
315 <td>Name of the Ant property to set.</td>
316 <td><i>none (required)</i></td>
317 </tr>
318 <tr>
319 <td colspan="3"><i>All attributes of the <code>coverage</code> task.</i></td>
320 </tr>
321 </tbody>
322</table>
323
324
325<h2><a name="dump">Task <code>dump</code></a></h2>
326
327<p>
328 This task allows to remotely collect execution data from another JVM without
329 stopping it. For example:
330</p>
331
332<pre class="source lang-xml linenums">
333&lt;jacoco:dump address="server.example.com" reset="true" destfile="remote.exec"/&gt;
334</pre>
335
336<p>
337 Remote dumps are usefull for long running Java processes like application
338 servers.
339</p>
340
341<p class="hint">
342 The target JVM needs to have a <a href="agent.html">JaCoCo agent</a>
343 configured with <code>output</code> mode <code>tcpserver</code>. See
344 <a href="#coverage"><code>coverage</code></a> and
345 <a href="#agent"><code>agent</code></a> tasks above.
346</p>
347
348<p>
349 The <code>dump</code> task has the following attributes:
350</p>
351
352<table class="coverage">
353 <thead>
354 <tr>
355 <td>Attribute</td>
356 <td>Description</td>
357 <td>Default</td>
358 </tr>
359 </thead>
360 <tbody>
361 <tr>
362 <td><code>address</code></td>
363 <td>Target IP address or DNS name.</td>
364 <td><code>localhost</code></td>
365 </tr>
366 <tr>
367 <td><code>port</code></td>
368 <td>Target TCP port.</td>
369 <td><code>6300</code></td>
370 </tr>
371 <tr>
372 <td><code>dump</code></td>
373 <td>Flag whether execution data should be dumped.</td>
374 <td><code>true</code></td>
375 </tr>
376 <tr>
377 <td><code>reset</code></td>
378 <td>Flag whether execution data should be reset in the target agent after
379 the dump.</td>
380 <td><code>false</code></td>
381 </tr>
382 <tr>
383 <td><code>destfile</code></td>
384 <td>File location to write the collected execution data to.</td>
385 <td><i>none (required if dump=true)</i></td>
386 </tr>
387 <tr>
388 <td><code>append</code></td>
389 <td>If set to <code>true</code> and the execution data file already
390 exists, coverage data is appended to the existing file. If set to
391 <code>false</code>, an existing execution data file will be replaced.
392 </td>
393 <td><code>true</code></td>
394 </tr>
395 </tbody>
396</table>
397
398
399<h2><a name="merge">Task <code>merge</code></a></h2>
400
401<p>
402 This task can be used to merge the execution data from multiple test runs
403 into a single data store.
404</p>
405
406<pre class="source lang-xml linenums">
407&lt;jacoco:merge destfile="merged.exec"&gt;
408 &lt;fileset dir="executionData" includes="*.exec"/&gt;
409&lt;/jacoco:merge&gt;
410</pre>
411
412<p>
413 The task definition can contain any number of resource collection types and
414 has the following mandatory attribute:
415</p>
416
417<table class="coverage">
418 <thead>
419 <tr>
420 <td>Attribute</td>
421 <td>Description</td>
422 <td>Default</td>
423 </tr>
424 </thead>
425 <tbody>
426 <tr>
427 <td><code>destfile</code></td>
428 <td>File location to write the merged execution data to.</td>
429 <td><i>none (required)</i></td>
430 </tr>
431 </tbody>
432</table>
433
434
435<h2><a name="report">Task <code>report</code></a></h2>
436
437<p>
438 Finally different reports can be created with the <code>report</code> task.
439 A report task declaration consists of different sections, two specify the
440 input data, additional ones specify the output formats:
441</p>
442
443<pre class="source lang-xml linenums">
444&lt;jacoco:report&gt;
445
446 &lt;executiondata&gt;
447 &lt;file file="jacoco.exec"/&gt;
448 &lt;/executiondata&gt;
449
450 &lt;structure name="Example Project"&gt;
451 &lt;classfiles&gt;
452 &lt;fileset dir="classes"/&gt;
453 &lt;/classfiles&gt;
454 &lt;sourcefiles encoding="UTF-8"&gt;
455 &lt;fileset dir="src"/&gt;
456 &lt;/sourcefiles&gt;
457 &lt;/structure&gt;
458
459 &lt;html destdir="report"/&gt;
460
461&lt;/jacoco:report&gt;
462</pre>
463
464<p>
465 As you can see from the example above the <code>report</code> task is based
466 on several nested elements:
467</p>
468
469<h3>Element <code>executiondata</code></h3>
470
471<p>
472 Within this element Ant resources and resource collections can be specified,
473 that represent JaCoCo execution data files. If more than one execution data
474 file is specified, execution data is combined. A particular piece of code is
475 considered executed when it is marked as such in any of the input files.
476</p>
477
478<h3>Element <code>structure</code></h3>
479
480<p>
481 This element defines the report structure. It might contain the following
482 nested elements:
483</p>
484
485<ul>
486 <li><code>classfiles</code>: Container element for Ant resources and resource
487 collections that can specify Java class files, ZIP archive files (jar, war,
488 ear etc.) or folders containing class files. Archives and folders are
489 searched recursively for class files.</li>
490 <li><code>sourcefiles</code>: Optional container element for Ant resources and
491 resource collections that specify corresponding source files. If source
Marc R. Hoffmann8b5d6a32012-01-18 20:24:45 +0000492 files are specified, some report formats include highlighted source code.
493 Source files can be specified as individual files or as source directories.</li>
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000494</ul>
495
496<p>
497 The <code>sourcefiles</code> element has these optional attributes:
498</p>
499
500<table class="coverage">
501 <thead>
502 <tr>
503 <td>Attribute</td>
504 <td>Description</td>
505 <td>Default</td>
506 </tr>
507 </thead>
508 <tbody>
509 <tr>
510 <td><code>encoding</code></td>
511 <td>Character encoding of the source files.</td>
512 <td>Platform default encoding</td>
513 </tr>
514 <tr>
515 <td><code>tabwidth</code></td>
516 <td>Number of whitespace characters that represent a tab character.</td>
517 <td>4 characters</td>
518 </tr>
519 </tbody>
520</table>
521
Marc R. Hoffmann8b5d6a32012-01-18 20:24:45 +0000522<p class="hint">
523 <b>Important:</b> Source file resources must always be specified relative to
524 the respective source folder. If directory resources are given, they must
525 directly point to source folders. Otherwise source lookup will not succeed.
526</p>
527
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000528<p>
529 Note that the <code>classfiles</code> and <code>sourcefiles</code> elements
530 accept any
531 <a href="http://ant.apache.org/manual/Types/resources.html#collection">Ant
532 resource collection</a>. Therefore also filtering the class file set is
533 possible and allows to narrow the scope of the report, for example:
534</p>
535
536<pre class="source lang-xml linenums">
537&lt;classfiles&gt;
538 &lt;fileset dir="classes"&gt;
539 &lt;include name="org/jacoco/examples/important/**/*.class"/&gt;
540 &lt;/fileset&gt;
541&lt;/classfiles&gt;
542</pre>
543
544<p class="hint">
545 <b>Performance Warning:</b> Although it is technically possible and sometimes
546 convenient to use Ant's <code>zipfileset</code> to specify class or source
547 files, this resource type has poor performance characteristics and comes with
548 an huge memory overhead especially for large scale projects.
549</p>
550
551<p>
552 The structure can be refined with a hierarchy of <code>group</code> elements.
553 This way the coverage report can reflect different modules of a software
554 project. For each group element the corresponding class and source files can
555 be specified separately. For example:
556</p>
557
558<pre class="source lang-xml linenums">
559&lt;structure name="Example Project"&gt;
560 &lt;group name="Server"&gt;
561 &lt;classfiles&gt;
562 &lt;fileset dir="${workspace.dir}/org.jacoco.example.server/classes"/&gt;
563 &lt;/classfiles&gt;
564 &lt;sourcefiles&gt;
565 &lt;fileset dir="${workspace.dir}/org.jacoco.example.server/src"/&gt;
566 &lt;/sourcefiles&gt;
567 &lt;/group&gt;
568 &lt;group name="Client"&gt;
569 &lt;classfiles&gt;
570 &lt;fileset dir="${workspace.dir}/org.jacoco.example.client/classes"/&gt;
571 &lt;/classfiles&gt;
572 &lt;sourcefiles&gt;
573 &lt;fileset dir="${workspace.dir}/org.jacoco.example.client/src"/&gt;
574 &lt;/sourcefiles&gt;
575 &lt;/group&gt;
576
577 ...
578
579&lt;/structure&gt;
580</pre>
581
582<p>
583 Both <code>structure</code> and <code>group</code> elements have the following
584 mandatory attribute:
585</p>
586
587<table class="coverage">
588 <thead>
589 <tr>
590 <td>Attribute</td>
591 <td>Description</td>
592 <td>Default</td>
593 </tr>
594 </thead>
595 <tbody>
596 <tr>
597 <td><code>name</code></td>
598 <td>Name of the structure or group.</td>
599 <td><i>none (required)</i></td>
600 </tr>
601 </tbody>
602</table>
603
604<h3>Element <code>html</code></h3>
605
606<p>
607 Create a multi-page report in HTML format. The report can either be written as
608 multiple files into a directory or compressed into a single ZIP file.
609</p>
610
611<table class="coverage">
612 <thead>
613 <tr>
614 <td>Attribute</td>
615 <td>Description</td>
616 <td>Default</td>
617 </tr>
618 </thead>
619 <tbody>
620 <tr>
621 <td><code>destdir</code></td>
622 <td>Directory to create the report in. Either this property or
623 <code>destfile</code> has to be supplied.</td>
624 <td><i>none (required)</i></td>
625 </tr>
626 <tr>
627 <td><code>destfile</code></td>
628 <td>Zip file to create the report in. Either this property or
629 <code>destdir</code> has to be supplied.</td>
630 <td><i>none (required)</i></td>
631 </tr>
632 <tr>
633 <td><code>footer</code></td>
634 <td>Footer text for each report page.</td>
635 <td><i>no footer</i></td>
636 </tr>
637 <tr>
638 <td><code>encoding</code></td>
639 <td>Character encoding of generated HTML pages.</td>
640 <td><code>UTF-8</code></td>
641 </tr>
642 <tr>
643 <td><code>locale</code></td>
644 <td>Locale specified as ISO code (en, fr, jp, ...) used for number formating.</td>
645 <td><i>platform locale</i></td>
646 </tr>
647 </tbody>
648</table>
649
650<h3>Element <code>xml</code></h3>
651
652<p>
653 Create a single-file report in XML format.
654</p>
655
656<table class="coverage">
657 <thead>
658 <tr>
659 <td>Attribute</td>
660 <td>Description</td>
661 <td>Default</td>
662 </tr>
663 </thead>
664 <tbody>
665 <tr>
666 <td><code>destfile</code></td>
667 <td>Location to write the report file to.</td>
668 <td><i>none (required)</i></td>
669 </tr>
670 <tr>
671 <td><code>encoding</code></td>
672 <td>Encoding of the generated XML document.</td>
673 <td><code>UTF-8</code></td>
674 </tr>
675 </tbody>
676</table>
677
678<h3>Element <code>csv</code></h3>
679
680<p>
681 Create single-file report in CSV format.
682</p>
683
684<table class="coverage">
685 <thead>
686 <tr>
687 <td>Attribute</td>
688 <td>Description</td>
689 <td>Default</td>
690 </tr>
691 </thead>
692 <tbody>
693 <tr>
694 <td><code>destfile</code></td>
695 <td>Location to write the report file to.</td>
696 <td><i>none (required)</i></td>
697 </tr>
698 <tr>
699 <td><code>encoding</code></td>
700 <td>Encoding of the generated CSV document.</td>
701 <td><code>UTF-8</code></td>
702 </tr>
703 </tbody>
704</table>
705
Marc R. Hoffmann235a09e2012-12-23 15:57:16 +0100706
707<h2><a name="instrument">Task <code>instrument</code></a></h2>
708
709<p>
710 This task is used for <a href="offline.html">offline instrumentation</a> of
Marc R. Hoffmannadf2bf62012-12-28 20:56:45 +0100711 class files. The task takes a set of files and writes instrumented
712 versions to a specified location. The task takes any file type as input. Java
713 class files are instrumented. Archives are searched recursively for class files
714 which then get instrumented. All other files are copied without modification.
Marc R. Hoffmann235a09e2012-12-23 15:57:16 +0100715</p>
716
717<pre class="source lang-xml linenums">
718&lt;jacoco:instrument destfile="target/classes-instr"&gt;
719 &lt;fileset dir="target/classes" includes="**/*.class"/&gt;
720&lt;/jacoco:instrument&gt;
721</pre>
722
723<p>
724 The task definition can contain any number of resource collection types and
725 has the following mandatory attribute:
726</p>
727
728<table class="coverage">
729 <thead>
730 <tr>
731 <td>Attribute</td>
732 <td>Description</td>
733 <td>Default</td>
734 </tr>
735 </thead>
736 <tbody>
737 <tr>
738 <td><code>destdir</code></td>
Marc R. Hoffmannadf2bf62012-12-28 20:56:45 +0100739 <td>Directory location to write the instrumented files to.</td>
Marc R. Hoffmann235a09e2012-12-23 15:57:16 +0100740 <td><i>none (required)</i></td>
741 </tr>
742 </tbody>
743</table>
744
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000745</div>
746<div class="footer">
747 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
748 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
749</div>
750
751</body>
752</html>