title: Gradle jacoco coverage report with more than one submodule(s)?
body: <p>Does anybody know how to configure a gradle file for java jacoco report
  that contain codecoverage of more than one gradle submodule?</p>
  
  <p>my current approach only shows codecoverage of the current submodule but not
  codecoverage of a sibling-submodul.</p>
  
  <p>I have this project structure</p>
  
  <pre><code>- build.gradle (1)
  - corelib/
      - build.gradle (2)
      - src/main/java/package/Core.java
  - extlib/
      - build.gradle (3)
      - src/main/java/package/Ext.java
      - src/test/java/package/Integrationtest.java
  </code></pre>
  
  <p>when i execute <code>gradlew :extlib:check :extlib:jacocoTestReport</code> the junit-test "Integrationtest.java"
  is executed and a codecoverage report is generated that does not contain codecoverage for corelib classes like Core.java </p>
  
  <p>The result should include the codecoverage of Ext.java and Core.java</p>
  
  <p>I already read</p>
  
  <ul>
  <li><a href="https://docs.gradle.org/current/userguide/jacoco_plugin.html" rel="noreferrer">https://docs.gradle.org/current/userguide/jacoco_plugin.html</a> </li>
  <li>and <a href="https://stackoverflow.com/questions/29887805/filter-jacoco-coverage-reports-with-gradle">Filter JaCoCo coverage reports with Gradle</a></li>
  </ul>
  
  <p>but found no clues</p>
  
  <p>here is content of the gradle files</p>
  
  <pre><code>// root build.gradle (1)
  // Top-level build file where you can add configuration options 
  // common to all sub-projects/modules.
  buildscript {
      repositories {
          jcenter()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
      }
  }
  allprojects {
      repositories {
          jcenter()
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// build.gradle (2) subproject build file for corelib.
  apply plugin: 'java'
  apply plugin: 'jacoco'
  
  dependencies {
  }
  
  jacocoTestReport {
      reports {
          xml.enabled true
          html.enabled true
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// build.gradle (3) subproject build file for extlib.
  apply plugin: 'java'
  apply plugin: 'jacoco'
  
  dependencies {
      compile project(':corelib')
      testCompile 'junit:junit:4.11'
  
      // this does not compile
      // jacocoTestReport project(':pixymeta-core-lib')
  }
  
  jacocoTestReport {
      reports {
          xml.enabled true
          html.enabled true
      }
  }
  
  // workaround because android-studio does not make the test resources available
  // see https://code.google.com/p/android/issues/detail?id=64887#c13
  task copyTestResources(type: Copy) {
      from sourceSets.test.resources
      into sourceSets.test.output.classesDir
  }
  processTestResources.dependsOn copyTestResources
  </code></pre>
  
  <hr>
  
  <p>[Update 2016-08-01]</p>
  
  <p>thanks to @Benjamin Muschko i also tried in the root gradle file</p>
  
  <pre><code>// https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/6
  // https://docs.gradle.org/current/dsl/org.gradle.testing.jacoco.tasks.JacocoMerge.html
  task jacocoMerge(type: JacocoMerge) {
     subprojects.each { subproject -&gt;
        executionData subproject.tasks.withType(Test)
     } 
  
  }
  </code></pre>
  
  <p>but got error message (with gradle-2.14)</p>
  
  <pre><code>* What went wrong:
  Some problems were found with the configuration of task ':jacocoMerge'.
  &gt; No value has been specified for property 'jacocoClasspath'.
  &gt; No value has been specified for property 'executionData'.
  &gt; No value has been specified for property 'destinationFile'.
  </code></pre>
  
  <hr>
  
  <p>there is also the gradle plugin <a href="https://github.com/paveldudka/JacocoEverywhere" rel="noreferrer">https://github.com/paveldudka/JacocoEverywhere</a> where i have asked for mulit-submodule support <a href="https://github.com/paveldudka/JacocoEverywhere/issues/16" rel="noreferrer">https://github.com/paveldudka/JacocoEverywhere/issues/16</a></p>
  
  <p>[update 2016-08-01] i found a working solution based on <a href="https://github.com/palantir/gradle-jacoco-coverage" rel="noreferrer">https://github.com/palantir/gradle-jacoco-coverage</a></p>
  
  <p>See my own answer below</p>