Marc R. Hoffmann | e571f3f | 2012-05-13 12:18:02 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 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> |
Marc R. Hoffmann | e571f3f | 2012-05-13 12:18:02 +0000 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Evgeny Mandrikov | 8b21298 | 2016-06-12 17:55:49 +0200 | [diff] [blame] | 6 | <link rel="stylesheet" href="resources/doc.css" charset="UTF-8" type="text/css" /> |
Evgeny Mandrikov | 28d5985 | 2016-06-11 12:41:17 +0200 | [diff] [blame] | 7 | <link rel="stylesheet" href="../coverage/jacoco-resources/prettify.css" charset="UTF-8" type="text/css" /> |
Evgeny Mandrikov | 8b21298 | 2016-06-12 17:55:49 +0200 | [diff] [blame] | 8 | <link rel="shortcut icon" href="resources/report.gif" type="image/gif" /> |
Evgeny Mandrikov | 28d5985 | 2016-06-11 12:41:17 +0200 | [diff] [blame] | 9 | <script type="text/javascript" src="../coverage/jacoco-resources/prettify.js"></script> |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 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 | |
Mirko Friedenhagen | 56afd72 | 2014-04-17 22:22:47 +0200 | [diff] [blame] | 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 | |
Marc R. Hoffmann | 7830927 | 2012-05-02 19:25:44 +0000 | [diff] [blame] | 44 | <h2>Example</h2> |
| 45 | |
Mirko Friedenhagen | 4c0198c | 2013-11-22 22:01:23 +0100 | [diff] [blame] | 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> |
Marc R. Hoffmann | 7830927 | 2012-05-02 19:25:44 +0000 | [diff] [blame] | 64 | folder of the distribution. |
Mirko Friedenhagen | 4c0198c | 2013-11-22 22:01:23 +0100 | [diff] [blame] | 65 | </li> |
Marc R. Hoffmann | d718701 | 2014-01-06 23:22:22 +0100 | [diff] [blame] | 66 | </ul> |
Marc R. Hoffmann | 7830927 | 2012-05-02 19:25:44 +0000 | [diff] [blame] | 67 | |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 68 | |
| 69 | <h2>Prerequisites</h2> |
| 70 | |
| 71 | <p> |
Marc R. Hoffmann | 91b9962 | 2012-05-02 17:35:14 +0000 | [diff] [blame] | 72 | The JaCoCo Maven plug-in requires |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 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> |
Marc R. Hoffmann | 91b9962 | 2012-05-02 17:35:14 +0000 | [diff] [blame] | 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. |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 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> |
Marc R. Hoffmann | 91b9962 | 2012-05-02 17:35:14 +0000 | [diff] [blame] | 99 | To receive a full list of goals and available parameters you can use |
| 100 | <code>maven-help-plugin</code>: |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 101 | </p> |
| 102 | <pre> |
| 103 | mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail |
| 104 | </pre> |
| 105 | |
Evgeny Mandrikov | b0c293e | 2016-06-05 18:47:35 +0200 | [diff] [blame] | 106 | <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 | <project> |
| 114 | <reporting> |
| 115 | <plugins> |
| 116 | <plugin> |
| 117 | <groupId>org.jacoco</groupId> |
| 118 | <artifactId>jacoco-maven-plugin</artifactId> |
| 119 | <reportSets> |
| 120 | <reportSet> |
| 121 | <reports> |
| 122 | <!-- select non-aggregate reports --> |
| 123 | <report>report</report> |
| 124 | </reports> |
| 125 | </reportSet> |
| 126 | </reportSets> |
| 127 | </plugin> |
| 128 | </plugins> |
| 129 | </reporting> |
| 130 | </project> |
| 131 | </pre> |
| 132 | |
Marc R. Hoffmann | 871836b | 2012-05-12 12:28:13 +0000 | [diff] [blame] | 133 | <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 Friedenhagen | 4c0198c | 2013-11-22 22:01:23 +0100 | [diff] [blame] | 142 | <li><a href="prepare-agent-integration-mojo.html">prepare-agent-integration</a></li> |
Marc R. Hoffmann | f5fa1a8 | 2013-11-10 14:09:23 +0100 | [diff] [blame] | 143 | <li><a href="merge-mojo.html">merge</a></li> |
Marc R. Hoffmann | 871836b | 2012-05-12 12:28:13 +0000 | [diff] [blame] | 144 | <li><a href="report-mojo.html">report</a></li> |
Marc R. Hoffmann | 4b99022 | 2014-01-06 21:51:23 +0100 | [diff] [blame] | 145 | <li><a href="report-integration-mojo.html">report-integration</a></li> |
Marc R. Hoffmann | c181f60 | 2016-04-19 13:22:01 +0200 | [diff] [blame] | 146 | <li><a href="report-aggregate-mojo.html">report-aggregate</a></li> |
Kyle Lieber | 7bcacd3 | 2012-11-06 21:48:33 -0600 | [diff] [blame] | 147 | <li><a href="check-mojo.html">check</a></li> |
Marc R. Hoffmann | f5fa1a8 | 2013-11-10 14:09:23 +0100 | [diff] [blame] | 148 | <li><a href="dump-mojo.html">dump</a></li> |
Evgeny Mandrikov | e6f41d4 | 2013-01-11 15:37:36 +0100 | [diff] [blame] | 149 | <li><a href="instrument-mojo.html">instrument</a></li> |
Evgeny Mandrikov | ccff137 | 2013-01-11 17:04:01 +0100 | [diff] [blame] | 150 | <li><a href="restore-instrumented-classes-mojo.html">restore-instrumented-classes</a></li> |
Marc R. Hoffmann | 871836b | 2012-05-12 12:28:13 +0000 | [diff] [blame] | 151 | </ul> |
| 152 | |
Evgeny Mandrikov | 82a92ca | 2012-01-15 20:25:48 +0000 | [diff] [blame] | 153 | </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> © @copyright.years@ Mountainminds GmbH & Co. KG and Contributors |
| 157 | </div> |
| 158 | |
| 159 | </body> |
| 160 | </html> |