1
votes

This is not an android project with mixed source Java and Kotlin. Eventhough many have had issues with coverage, kotlin and sonar. I didn't find one for this case.

Sonarqube is not picking up both Kotlin and Java Coverage generated by Jacoco:

  • Gradle 4.8
  • Java 1.8
  • Kotlin 1.3.50

It gets the Java one, but all of the Kotlin classes gets ignored. I have applied all required plugin in the gradle file:

allprojects {
    apply plugin: 'jacoco'
    apply plugin: 'java'
    apply plugin: 'org.sonarqube'
    apply plugin: 'kotlin'

   ...
}
1

1 Answers

1
votes

First make sure your jacocoTestReport creates a xml report:

jacocoTestReport {
    reports {
        xml {
            enabled true
        }
        xml.destination "build/reports/jacocoTestReport.xml"
    }
} 

Then you will need to force those xml reports into sonar using the xmlReportPaths property in sonaqube for all projects.

You can see multiple paths here, that's in case you have multiple sub projects in your projects which also have mixed source Java / Kotlin.

sonarqube {
        properties {
            property "sonar.java.coveragePlugin", "jacoco"
            property("sonar.coverage.jacoco.xmlReportPaths", "../../build/reports/jacocoTestReport.xml,../build/reports/jacocoTestReport.xml")
        }
}

With that sonar will consider all the xml reports and generate the whole coverage.