title: How do I generate a JaCoCo report for a JAR file?
body: <p>We are trying to report code coverage of tests against a pre-packaged JAR file using JaCoCo. To do this we start the JAR file using <code>java -jar</code> with the additional argument:</p>
  
  <pre><code>-javaagent:${project.basedir}/tools/jacocoagent.jar=output=tcpserver,port=${jacoco.port}
  </code></pre>
  
  <p>JaCoCo's Maven plugin is configured to then dump the execution file and report the results:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt;
      &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
      &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;0.8.0&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;dumpData&lt;/id&gt;
              &lt;phase&gt;post-integration-test&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;dump&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;address&gt;localhost&lt;/address&gt;
                  &lt;port&gt;${jacoco.port}&lt;/port&gt;
                  &lt;destFile&gt;target/jacoco.exec&lt;/destFile&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
          &lt;execution&gt;
              &lt;id&gt;report&lt;/id&gt;
              &lt;phase&gt;verify&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;report&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;dataFile&gt;target/jacoco.exec&lt;/dataFile&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>This works to the point that a <code>jacoco.exec</code> file is generated which has a non-zero size (~350kB). </p>
  
  <p>But the report shows no coverage at all. Following the "Sessions" link I can see the classes in the JAR listed, but the report's home page shows this:
  <a href="https://i.stack.imgur.com/7nIGo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7nIGo.png" alt="JaCoCo Report"></a></p>
  
  <p>Based on the logs we have the code seems to be exercised. Is there a step missing in the JaCoCo setup or should this work?</p>