title: How to create an aggregated Jacoco report for a multi-module project?
body: <p>I have been looking for a solution for days for merging multiple <code>Jacoco</code> reports for a multi-module Android project in order to send them off to <code>Sonarcloud</code> at once. I have already checked tons of Stackoverflow posts and other things such as blogs, Github repositories, <a href="https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/18" rel="noreferrer">Gradle forum</a>, etc but unfortunately none of solutions works for me.</p>
  <p>I would really appreciate if anybody here shares a sample project or code piece with me.</p>
  <pre><code>Gradle version: 7.0.2
  Kotlin version: 1.5.21
  JDK: 11
  </code></pre>
  <p>Below code piece also doesn't work for me</p>
  <pre><code>/**
   *  Root task that generates an aggregated Jacoco test coverage report for all sub-projects
   */
  task jacocoFullReport(type: JacocoReport, group: 'Coverage reports') {
      group = 'Reporting'
      description = 'Generates an aggregate report from all subprojects'
  
      tasks.withType(Test) {
          ignoreFailures true
      }
  
      def projects = subprojects
  
      //noinspection GrUnresolvedAccess
      dependsOn(projects.jacocoReport)
  
      final source = files(projects.jacocoReport.sourceDirectories)
  
      additionalSourceDirs.setFrom source
      sourceDirectories.setFrom source
  
      classDirectories.setFrom files(projects.jacocoReport.classDirectories)
      executionData.setFrom files(projects.jacocoReport.executionData)
  
      reports {
          html {
              enabled true
              destination file('build/reports/jacoco/html')
          }
          csv {
              enabled true
              destination file('build/reports/jacoco/jacocoFullReport.csv')
          }
      }
  
      doFirst {
          //noinspection GroovyAssignabilityCheck
          executionData.setFrom files(executionData.findAll { it.exists() })
      }
  }
  </code></pre>