SonarKotlin code coverage


Sonar doesn’t display coverage information after analysis of my Kotlin project with the new SonarKotlin (official) plugin (I was working with another non-official Kotlin plugin).

Jacoco configuration :
property “sonar.jacoco.reportPaths”, “${project.buildDir}/jacoco/testDebugUnitTest.exec”

Version used:
sonar gradle plugin 2.6.2

Is there another way to use the result of jacoco analysis ?

Hello Grégory,

With the new SonarKotlin, it is not yet possible to import JaCoCo reports. We are working on it and this time the idea is to support the XML format instead of the binary one. See for more details.


1 Like

Hi Alexandre,

I see that the ticket is currently in Test. Do you have a plan released date for the support of Jacoco reports in SonarSource ?


Hi Alexandre,

I already tried to send Kotlin Code Coverage (, but it didnt show up on Sonarqube, it shows 0% coverage. I already set the xml.enabled to true and make sure the xml file is there.

This is how it looks on my project:
property “sonar.coverage.jacoco.xmlReportPaths”, “build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml”

There is no problem with Java coverage. I use Kotlin + Java in my project.

Did I do anything wrong with the script? Any help is appreciated.
I use sonarqube Version 7.1 (build 11001) on docker

Thank you.

jacoco reports are still not picked up with sonar.coverage.jacoco.xmlReportPaths as explained here:

is this feature not yet available on SonarCloud?

Edit Tt tries to pick it up but seems to have problems due to line-number mismatches which is quite common in kotlin due to inline functions and such :frowning:

Excuse my ignorance but is this something that needs to be rolled out to

I can’t tell what happens to MMF-1362 in terms of higher level processes.

On my side I’m using the 2.6.2 of the org.sonarqube Gradle plugin to try to send the XML report to and my has: systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml

I am using that exactly same configuration, and my project is working showing coverage. But I am running on some issues, because it is not grabbing the coverage of all my classes. There some classes showing the right coverage, but some others are showing 0%. I think there are some issues in this plugin.

property “sonar.coverage.jacoco.xmlReportPaths”, “build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml”

Also Please note that in the documentation says that you need to have the JaCoCo plugin on your server instance. After I install this plugin, I started getting the coverage. Before, with the sonar detekt plugin, I didn’t need to have the jacoco one installed.

My project is Android + gradle + kotlin.

1 Like

Thank you Manuel! That’s right, I need to install jacoco plugin on the server. My coverage is now showing. And as far as I checked, I have no issue yet regarding the 0% coverage for some files. However, I’ll keep checking and will pop out here if I find something.


1 Like


I confirm SonarJaCoCo 1.0.0 is installed on ( and I’m waiting for the 1.0.1 to be installed very soon to handle the case described in



Hi Alexandre,

I am using the SonarJaCoCo version 1.0.1 and SonarKotlin 1.2 in my own sonar installation, and I am getting errors with some classes, where the coverage can not be retrieved. So for that specific class I am getting 0% coverage, but with others I can see the right one.

This is an example of one error I am getting:

Cannot import coverage information for file 'src/main/java/com/SomeClass.kt', coverage data is invalid. Error: {}
java.lang.IllegalStateException: Line 76 is out of range in the file src/main/java/com/SomeClass.kt (lines: 75)
    at org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage.validateLine(

It seems to be the same error described in How should I proceed? Do I need to create a ticket? I am new here, so it would be great you could help me.


Hello Manuel,

This message “Cannot import coverage information for file” is exactly the fix we did this week to prevent the full code scan to stop because the JaCoCo XML file is containing invalid data.
This is now expected to have it on a couple of files and have 0% of coverage for these files in SonarQube.

Once will be fixed on JaCoCo side, I do expect these messages to disappear.


1 Like

Oh, I see. Then this is a jacoco issue. Nothing to do with Sonar.

Thank you very much for your clarification!

FYI, SonarJaCoCo 1.0.1 and SonarKotlin 1.2.1 are now installed on

1 Like

Does anyone have a working sample project with gradle + kotlin +

I’m at the point where I’m more than willing to part with cash just for a working configuration.

I have an apparently broken configuration here:

If after execution of gradle test jacocoTestReport you’ll open build/reports/jacoco/test/html/index.html, then you can notice that content of source files is not shown, whereas normally it is - see for example

Somewhat similar happens with SonarQube: build/reports/jacoco/test/jacocoTestReport.xml contains

<package name="com/thorgil/cashbook/dataproviders/">
  <sourcefile name="BusinessTransactionDataProvider.kt">

so SonarQube JaCoCo Plugin tries to find file whose path ends by com/thorgil/cashbook/dataproviders/BusinessTransactionDataProvider.kt - relevant code is

however path to BusinessTransactionDataProvider.kt is src/main/kotlin/dataproviders/BusinessTransactionDataProvider.kt.

After moving this file to src/main/kotlin/com/thorgil/cashbook/dataproviders/BusinessTransactionDataProvider.kt and others to corresponding locations, you’ll see their sources in HTML report generated by JaCoCo and their coverage in :

Currently I get low coverage percentage (30%) because half of my files are throwing errors when uploading to sonarcloud.

Gettling errors like “Cannot import coverage information for file XXX. coverage data is invalid. Error: {}”
“java.lang.IllegalStateException: Line 22 is out of range in the file XXX (lines: 21)”.

I am using gradle + kotlin + spring boot.

Did anybody solved this?


Facing the same issue. Does anybody have a solution for that?

I’ve checked the JaCoCo HTML Reports and it looks correct.

It seems this issue is around for some time. I read all the remarks and posts here. I currently use jacoco maven plugin 0.8.2. This generates incorrect line numbers. At least for kotlin files. Is this wrong on jacoco side? Or doesn’t the SonarKotlin plugin translate correctly to kotlin file line numbers?


I tested with jacoco maven plugin version 0.8.3-SNAPSHOT. And linenumbers are fixed. At 15-11-2018 it was merged ( No release yet from jacoco.

@Alexandre_Gigleux You were right. It is fixed

1 Like

Thank you so much for helping me with this. I was at my wits end. I owe you a beer at the very least.

I’ve moved the files to the correct path, as expected by the SonarQube JaCoCo plugin, and it now works, coverage is showing up on for

Whoo hoo! I guess this is also a lesson learned the hard way (don’t abuse kotlin’s liberal nature when it comes to package naming and corresponding file paths).

For me the issue with the line number get fixed adding
jacoco {
toolVersion = “0.8.3”
reportsDir = file("$buildDir/reports")

1 Like