title: Gradle, Kotlin, Junit5 and Jacoco - 0% coverage reported
body: <p>We would like to use Gradle in conjunction with Kotlin and Jacoco (+JUnit 5) for generating a code coverage report.</p>
  
  <p>Our project directory tree looks as follows:</p>
  
  <p><code>project/{src,test}/main/kotlin ...</code></p>
  
  <p>Our build.gradle file looks as follows:</p>
  
  <pre><code>jacoco {
      toolVersion = "0.7.9"
      reportsDir = file("$buildDir/reports")
      applyTo junitPlatformTest
  }
  jacocoTestReport {
      group = "Reporting"
      description = "Generate Jacoco coverage report."
      classDirectories = fileTree(
              dir: "$buildDir/classes/kotlin/main"
      )
      def coverageSourceDirs = [
              "src/main/kotlin"
      ]
      additionalSourceDirs = files(coverageSourceDirs)
      sourceDirectories = files(coverageSourceDirs)
      executionData = files("$buildDir/jacoco/junitPlatformTest.exec")
      reports {
          xml.enabled = true
          html.enabled = true
          csv.enabled = true
      }
  
  }
  test {
      jacoco {
          append = false
          destinationFile = file("$buildDir/jacoco/junitPlatformTest.exec")
          includeNoLocationClasses = true
      }
  }
  test.dependsOn junitPlatformTest
  </code></pre>
  
  <p>With this configuration, Jacoco generates a html report and puts it under <code>build/reports/test/html</code>. However, it shows me 0% coverage. This should not be the case, because I have one test case that excercices all methods for a single dummy class in the project. </p>
  
  <p>I went through several posts such as:</p>
  
  <ul>
  <li><a href="http://vgaidarji.me/blog/2017/12/20/how-to-configure-jacoco-for-kotlin-and-java-project/" rel="nofollow noreferrer">http://vgaidarji.me/blog/2017/12/20/how-to-configure-jacoco-for-kotlin-and-java-project/</a></li>
  <li><a href="https://stackoverflow.com/questions/47499351/jacoco-is-reporting-0-coverage-of-kotlin-classes-by-unit-tests-in-an-android-pr?rq=1">Jacoco is reporting 0 coverage of Kotlin classes by unit tests, in an Android project</a></li>
  <li><a href="https://stackoverflow.com/questions/45464138/jacoco-returning-0-coverage-with-kotlin-and-android-3-0?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa">JaCoCo returning 0% Coverage with Kotlin and Android 3.0</a></li>
  </ul>
  
  <p>However, I could not quite find a solution that worked for me, yet. </p>