blob: 0546c1bcef9003f629da066f6af5f47803d4041d [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" />
Evgeny Mandrikov8b212982016-06-12 17:55:49 +02006 <link rel="stylesheet" href="resources/doc.css" charset="UTF-8" type="text/css" />
Evgeny Mandrikov28d59852016-06-11 12:41:17 +02007 <link rel="stylesheet" href="../coverage/jacoco-resources/prettify.css" charset="UTF-8" type="text/css" />
Evgeny Mandrikov8b212982016-06-12 17:55:49 +02008 <link rel="shortcut icon" href="resources/report.gif" type="image/gif" />
Evgeny Mandrikov28d59852016-06-11 12:41:17 +02009 <script type="text/javascript" src="../coverage/jacoco-resources/prettify.js"></script>
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000010 <title>JaCoCo - Maven Plug-in</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">Maven Plug-in</span>
18</div>
19<div id="content">
20
21<h1>Maven Plug-in</h1>
22
23<p>
24 The JaCoCo <a href="http://maven.apache.org/">Maven</a> plug-in provides the
25 JaCoCo runtime agent to your tests and allows basic report creation.
26</p>
27
28<p class="hint">
29 If you want to have line number information included in the coverage reports
30 or you want source code highlighting the class files of the test target must
31 be compiled with debug information.
32</p>
33
Mirko Friedenhagen56afd722014-04-17 22:22:47 +020034<p class="hint">
35 When using the <tt>maven-surefire-plugin</tt> or <tt>maven-failsafe-plugin</tt>
36 you <b>must not</b> use a
37 <a href="http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#forkCount">
38 <tt>forkCount</tt></a> of <tt>0</tt> or set the
39 <a href="http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#forkMode">
40 <tt>forkMode</tt></a> to <tt>never</tt> as this would prevent the execution of
41 the tests with the <tt>javaagent</tt> set and no coverage would be recorded.
42</p>
43
Marc R. Hoffmann78309272012-05-02 19:25:44 +000044<h2>Example</h2>
45
Mirko Friedenhagen4c0198c2013-11-22 22:01:23 +010046<ul>
47 <li>
48 The JaCoCo distribution contains a simple example how code coverage
49 can be added to a Maven project.</li>
50 <li>
51 This <a href="examples/build/pom.xml">POM file</a>
52 for a JAR project runs JUnit tests under code coverage and creates a coverage
53 report (<tt>target/site/jacoco/index.html</tt>).
54 </li>
55 <li>
56 This <a href="examples/build/pom-it.xml">POM file</a>
57 for a JAR project runs unit tests and integration tests under code coverage
58 and creates two coverage reports, one for unit tests (
59 <tt>target/site/jacoco/index.html</tt>) and one for integration tests (
60 <tt>target/site/jacoco-it/index.html</tt>).
61 </li>
62 <li>
63 The complete example is located in the <code>./doc/examples/build</code>
Marc R. Hoffmann78309272012-05-02 19:25:44 +000064 folder of the distribution.
Mirko Friedenhagen4c0198c2013-11-22 22:01:23 +010065 </li>
Marc R. Hoffmannd7187012014-01-06 23:22:22 +010066</ul>
Marc R. Hoffmann78309272012-05-02 19:25:44 +000067
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000068
69<h2>Prerequisites</h2>
70
71<p>
Marc R. Hoffmann91b99622012-05-02 17:35:14 +000072 The JaCoCo Maven plug-in requires
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000073</p>
74
75<ul>
76 <li>Maven 2.1.0 or higher and</li>
77 <li>Java 1.5 or higher (for both, the Maven runtime and the test executor).</li>
78</ul>
79
80
81<h2>Usage</h2>
82
83<p>
Marc R. Hoffmann91b99622012-05-02 17:35:14 +000084 The Maven plug-in can be included in your build with the following
85 declaration. Please check
86 <a href="http://search.maven.org/#search|ga|1|g%3Aorg.jacoco%20a%3Ajacoco-maven-plugin">here</a>
87 for the latest release version in the repository.
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +000088</p>
89
90<pre class="source lang-xml linenums">
91&lt;plugin&gt;
92 &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
93 &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
94 &lt;version&gt;@project.version@&lt;/version&gt;
95&lt;/plugin&gt;
96</pre>
97
98<p>
Marc R. Hoffmann91b99622012-05-02 17:35:14 +000099 To receive a full list of goals and available parameters you can use
100 <code>maven-help-plugin</code>:
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000101</p>
102<pre>
103mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail
104</pre>
105
Evgeny Mandrikovb0c293e2016-06-05 18:47:35 +0200106<p>
107 Usage of plugin together with <tt>maven-site-plugin</tt> without
108 <a href="https://maven.apache.org/plugins/maven-site-plugin/examples/configuring-reports.html#Selecting_Reports_from_a_Plugin:_Configuring_Report_Sets">explicit selection of reports</a>
109 might lead to generation of redundant aggregate reports.
110 Specify <tt>reportSets</tt> explicitly to avoid this:
111</p>
112<pre class="source lang-xml linenums">
113&lt;project&gt;
114 &lt;reporting&gt;
115 &lt;plugins&gt;
116 &lt;plugin&gt;
117 &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
118 &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
119 &lt;reportSets&gt;
120 &lt;reportSet&gt;
121 &lt;reports&gt;
122 &lt;!-- select non-aggregate reports --&gt;
123 &lt;report&gt;report&lt;/report&gt;
124 &lt;/reports&gt;
125 &lt;/reportSet&gt;
126 &lt;/reportSets&gt;
127 &lt;/plugin&gt;
128 &lt;/plugins&gt;
129 &lt;/reporting&gt;
130&lt;/project&gt;
131</pre>
132
Marc R. Hoffmann871836b2012-05-12 12:28:13 +0000133<h2>Goals</h2>
134
135<p>
136 The JaCoCo Maven plug-in defines the following goals:
137</p>
138
139<ul>
140 <li><a href="help-mojo.html">help</a></li>
141 <li><a href="prepare-agent-mojo.html">prepare-agent</a></li>
Mirko Friedenhagen4c0198c2013-11-22 22:01:23 +0100142 <li><a href="prepare-agent-integration-mojo.html">prepare-agent-integration</a></li>
Marc R. Hoffmannf5fa1a82013-11-10 14:09:23 +0100143 <li><a href="merge-mojo.html">merge</a></li>
Marc R. Hoffmann871836b2012-05-12 12:28:13 +0000144 <li><a href="report-mojo.html">report</a></li>
Marc R. Hoffmann4b990222014-01-06 21:51:23 +0100145 <li><a href="report-integration-mojo.html">report-integration</a></li>
Marc R. Hoffmannc181f602016-04-19 13:22:01 +0200146 <li><a href="report-aggregate-mojo.html">report-aggregate</a></li>
Kyle Lieber7bcacd32012-11-06 21:48:33 -0600147 <li><a href="check-mojo.html">check</a></li>
Marc R. Hoffmannf5fa1a82013-11-10 14:09:23 +0100148 <li><a href="dump-mojo.html">dump</a></li>
Evgeny Mandrikove6f41d42013-01-11 15:37:36 +0100149 <li><a href="instrument-mojo.html">instrument</a></li>
Evgeny Mandrikovccff1372013-01-11 17:04:01 +0100150 <li><a href="restore-instrumented-classes-mojo.html">restore-instrumented-classes</a></li>
Marc R. Hoffmann871836b2012-05-12 12:28:13 +0000151</ul>
152
Evgeny Mandrikov82a92ca2012-01-15 20:25:48 +0000153</div>
154<div class="footer">
155 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span>
156 <a href="license.html">Copyright</a> &copy; @copyright.years@ Mountainminds GmbH &amp; Co. KG and Contributors
157</div>
158
159</body>
160</html>