Issues mixing kotlin and java classes in Sonarqube coverage using gradle plugin


In one project in my company, a coverage issue in Sonarqube is faced. Following setup is done in the project:

  • Gradle
  • Mix of Kotlin and Java
  • Jacoco gradle plugin for coverage
  • Sonar gradle plugin (relying on Jacoco report to get the coverage)

The faced issue is about the sonar coverage on some kotlin classes. The Jacoco coverage is not reflected in SonarQube only for the kotlin classes (Java classes are properly covered).

Problem to reproduce

It is quite tough to describe my issue because I’m not able to reproduce the issue on a simple project, meaning I’m not able to find the root cause. At the opposite, I’m able to reproduce the issue in the project of my company. Unfortunately, I can’t share the code directly because it is confidential.

Ask for some help

After some investigation, I’ve not been able to find the root cause of my issue. Also, the following stackoverflow hint does not solve the problem:

I’m creating this topic to ask for some help. Does anyone has an idea of what could be the root cause of my issue?
By finding the root cause, I would be able to create a reproducer or to find a workarroung to share in a ticket here.

Thanks for your help.

To help, here is a picture of the sonar scan where we can see that coverage for kotlin classes only is 0%:

Hey there.

Take a look at the JaCoCo Report for your project (the xml file(s)). Do they show coverage on Kotlin files?


Yes indeed as you can see on following screenshot (I share the html report to visualise easily and the coverage is also present in the XML file):

Hello @chrhenry,

Thanks for your message. There is an example project of mixing kotlin and java files here (Unfortunately in Maven only, will add for Gradle soon)

There could be a problem if your kotlin files are not located in the directories structure corresponding to package names (java style, which is recommended in Java-Kotlin mixed projects) If your Kotlin files are not located in this directory Jacoco will not be able to find the source file and wont map coverage result to it. So SQ won’t show it. This issue doesn’t affect coverage report of Jacoco because Jacoco is using bytecode for its calculations. But you can probably notice some warnings that source files weren’t located.


To add to @Margarita_Nedzelska’s message – I would definitely check your .xml report to see if you find nodes related to your Kotlin files. That’s the information the scanner is seeing.

Thanks a lot @Margarita_Nedzelska and @Colin_SonarSource for these advices, I will take a look closely to these inputs and I let you know if I have some news or some new blockers.

Best regards


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.