1<?xml version="1.0" encoding="UTF-8" ?> 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=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" /> 8 <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 - 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> > 16 <a href="index.html" class="el_group">Documentation</a> > 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 34<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 44<h2>Example</h2> 45 46<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> 64 folder of the distribution. 65 </li> 66</ul> 67 68 69<h2>Prerequisites</h2> 70 71<p> 72 The JaCoCo Maven plug-in requires 73</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> 84 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. 88</p> 89 90<pre class="source lang-xml linenums"> 91<plugin> 92 <groupId>org.jacoco</groupId> 93 <artifactId>jacoco-maven-plugin</artifactId> 94 <version>@project.version@</version> 95</plugin> 96</pre> 97 98<p> 99 To receive a full list of goals and available parameters you can use 100 <code>maven-help-plugin</code>: 101</p> 102<pre> 103mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail 104</pre> 105 106<h2>Goals</h2> 107 108<p> 109 The JaCoCo Maven plug-in defines the following goals: 110</p> 111 112<ul> 113 <li><a href="help-mojo.html">help</a></li> 114 <li><a href="prepare-agent-mojo.html">prepare-agent</a></li> 115 <li><a href="prepare-agent-integration-mojo.html">prepare-agent-integration</a></li> 116 <li><a href="merge-mojo.html">merge</a></li> 117 <li><a href="report-mojo.html">report</a></li> 118 <li><a href="report-integration-mojo.html">report-integration</a></li> 119 <li><a href="check-mojo.html">check</a></li> 120 <li><a href="dump-mojo.html">dump</a></li> 121 <li><a href="instrument-mojo.html">instrument</a></li> 122 <li><a href="restore-instrumented-classes-mojo.html">restore-instrumented-classes</a></li> 123</ul> 124 125</div> 126<div class="footer"> 127 <span class="right"><a href="@jacoco.home.url@">JaCoCo</a> @qualified.bundle.version@</span> 128 <a href="license.html">Copyright</a> © @copyright.years@ Mountainminds GmbH & Co. KG and Contributors 129</div> 130 131</body> 132</html> 133