title: Merging Jacoco report files from multiple sources
body: <p>I have the following challenge which I would like to resolve. Here's a current setup:</p>
  
  <ul>
  <li>Jenkins</li>
  <li>Maven</li>
  <li>SonarQube</li>
  <li>Java application with multiple modules</li>
  </ul>
  
  <p>So currently in Jenkins we have 2 builds, one for normal delivery and another one to produce sonar reports.</p>
  
  <p>What we would like to do would be to have a build generated with the JaCoCo argument line and ship this one to our QA team in order to get better coverage numbers which we could append or merge with the numbers generated by the sonar build we make every day. The build sent to QA would be installed onto a different server than the one we are generating the build from.</p>
  
  <p>What would be the best approach to perform this. Eventually we would like to also get JaCoCo reports from our dev workstations and append those numbers to our sonar page.</p>
  
  <p><strong>EDIT 1</strong>
  Thank to details provided on this thread I was able to startup my multi-module application with the following JVM option : <code>"-javaagent:${MAIN_DIR}/lib/jacocoagent.jar==destfile=/jacoco.exec,output=tcpserver,address=*"</code></p>
  
  <p>In my Jenkins build I have Pre Steps going as follow : 
  An ant task that calls target jacocoReport.
  The build.xml I'm using for this purpose has the following code;
  
      
      </p>
  
  <pre><code>&lt;taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"&gt;
      &lt;classpath path="/opt/hudson/tools/jacocoant.jar"/&gt;
  &lt;/taskdef&gt;
  
  &lt;target name="jacocoReport"&gt;
          &lt;jacoco:dump address="${jacoco.host}" port="${jacoco.port}" dump="true" reset="true" destfile="${jacocoReportFile}" append="false"/&gt;
  &lt;/target&gt;
  
  &lt;target name="jacocoReset"&gt;
          &lt;jacoco:dump address="${jacoco.host}" port="${jacoco.port}" reset="true" destfile="${jacocoReportFile}" append="false"/&gt;
      &lt;delete file="${jacocoReportFile}"/&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p></p>
  
  <p>And finally I have a maven build step which calls sonar:sonar</p>
  
  <p>Here's the section in the POM relative to my integration report;</p>
  
  <pre><code>&lt;sonar.java.coveragePlugin&gt;jacoco&lt;/sonar.java.coveragePlugin&gt;
  &lt;sonar.dynamicAnalysis&gt;reuseReports&lt;/sonar.dynamicAnalysis&gt;
  &lt;sonar.jacoco.itReportPath&gt;${WORKSPACE}/it-jacoco.exec&lt;/sonar.jacoco.itReportPath&gt;
  &lt;sonar.language&gt;java&lt;/sonar.language&gt;
  &lt;sonar.branch&gt;9.9.5&lt;/sonar.branch&gt;
  </code></pre>
  
  <p>When the build finishes, my Sonar entry still shows at 0% for my integration tests. But when I take the same it-jacoco.exec report and import it using Eclipse's Jacoco import Coverage session, I get 26% coverage.</p>
  
  <p>Finally when I look into my Jenkins build logs I see the following;</p>
  
  <pre><code>Sensor JaCoCoItSensor...
  Analysing /var/lib/jenkins/workspace/XXXXXX/it-jacoco.exec
  No information about coverage per test.
  Sensor JaCoCoItSensor done: 34 ms
  </code></pre>