# Does SonarCloud support Kotlin Multiplatform?

**URL:** <https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849>\
**Category:** SonarQube Cloud\
**Tags:** kotlin\
**Created:** [May 16, 2019, 8:26pm UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849 "2019-05-16T20:26:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcornaz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jcornaz/32/1656_2.png) [@jcornaz](https://community.sonarsource.com/u/jcornaz)\
**Post date:** [May 16, 2019, 8:26pm UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/1 "2019-05-16T20:26:21Z")

</div>

SonarCloud doesn’t detect my Kotlin common code in a multiplatform project.

Is it something SonarCloud does not support yet, or am I doing something wrong?

```auto
    subprojects {
        sonarqube {
            properties {
                property("sonar.kotlin.detekt.reportPaths", "build/reports/detekt/detekt.xml")
                property("sonar.sources", files("src/commonMain/kotlin", "src/jvmMain/kotlin")) // I tried few alternatives, like use listOf and sourceSets.flatMap { it.allSources.srcDirs }
                property("sonar.test", files("src/commonTest/kotlin", "src/jvmTest/kotlin"))
            }
        }
    }

```

---

<div class="post-metadata">

**Author:** ![Lena](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lena/32/66719_2.png) [@Lena](https://community.sonarsource.com/u/Lena)\
**Post date:** [June 28, 2019, 3:24pm UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/3 "2019-06-28T15:24:10Z")

</div>

What do you mean by “a multiplatform project”?

What is this piece of configuration you added?  
Can you show logs of analysis?

---

<div class="post-metadata">

**Author:** ![jcornaz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jcornaz/32/1656_2.png) [@jcornaz](https://community.sonarsource.com/u/jcornaz)\
**Post date:** [July 28, 2019, 6:10pm UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/4 "2019-07-28T18:10:10Z")

</div>

> What do you mean by “a multiplatform project”?

- [Kotlin Multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html)
- [Building Kotlin multiplatform project](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html)

> What is this piece of configuration you added?

I’m not sure to understand the question.

The code snippet from my original post is nothing more than the sonarQube configuration for the probject.

Or you are talking about something else?

> Can you show logs of analysis?

Where can I find them?

---

<div class="post-metadata">

**Author:** ![Lena](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lena/32/66719_2.png) [@Lena](https://community.sonarsource.com/u/Lena)\
**Post date:** [July 31, 2019, 7:05am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/5 "2019-07-31T07:05:14Z")

</div>

> What is this piece of configuration you added?

I mean this code snippet you’ve put in the first message, to which file does it belong?

> Can you show logs of analysis?

These are logs printed when running `sonar-scanner`

---

<div class="post-metadata">

**Author:** ![jcornaz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jcornaz/32/1656_2.png) [@jcornaz](https://community.sonarsource.com/u/jcornaz)\
**Post date:** [August 12, 2019, 6:14am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/6 "2019-08-12T06:14:31Z")

</div>

> [@Lena](#):
>
> I mean this code snippet you’ve put in the first message, to which file does it belong?

As I said, it is the sonar configuration.

If the fact that it is configured from gradle disturbs you, here is a simpler equivalent:

```auto
sonar.kotlin.detekt.reportPaths=build/reports/detekt/detekt.xml
sonar.sources=src/commonMain/kotlin,src/jvmMain/kotlin
sonar.test=src/commonTest/kotlin,src/jvmTest/kotlin

```

> These are logs printed when running `sonar-scanner`

I don’t recall seeing any special logs.

But since I understood that sonarQube do not really support Kotlin, I stopped using it.

And right now I’m not willing to spend time to setup sonar again, just to reproduce this problem.

If you, however, manage to set up sonar for a kotlin multiplatform project, with code coverage properly reported, please share it.

---

<div class="post-metadata">

**Author:** ![Kamil\_Kaminski](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/kamil_kaminski/32/9906_2.png) [@Kamil\_Kaminski](https://community.sonarsource.com/u/Kamil_Kaminski)\
**Post date:** [March 4, 2020, 11:14am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/7 "2020-03-04T11:14:48Z")

</div>

I have the same issue: I have android project (gradle), with many modules. I have few regular java modules, few android library modules, and one Kotlin multiplatform module. In Java and Android lib modules I have mixed Java and Kotlin classes.

I managed to setup SonarQube and Jacoco for Java and Android modules (I have one shared configuration in top level build.gradle file). But I can’t manage how to upload to sonarqube my Kotlin multiplatform module.

I tried to modify sonarqube configuration in build.gradle in that Kotlin Multiplatform module, but without any success 😕

```auto
sonarqube {
    properties {
        property("sonar.sources", ["./src/commonMain/kotlin", "./src/iosMain/kotlin", "./src/jvmMain/kotlin"])
        property("sonar.tests", ["./src/commonTest/kotlin", "./src/iosTest/kotlin", "./src/jvmTest/kotlin"])
    }
}

```

I’m using SonarQube 7.9.2 LTS

---

<div class="post-metadata">

**Author:** ![Kamil\_Kaminski](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/kamil_kaminski/32/9906_2.png) [@Kamil\_Kaminski](https://community.sonarsource.com/u/Kamil_Kaminski)\
**Post date:** [March 10, 2020, 7:03am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/8 "2020-03-10T07:03:28Z")

</div>

I tried many ways of defining sonar properties for that Kotlin Multiplatform module, without any success 😕  
When I ran `./gradlew sonarqube --info` I can see following logs:

1. For a regular java module with Android and Kotlin:

```auto
------------- Run sensors on module MY_JAVA_MODULE
Sensor JavaSquidSensor [java]
Configured Java source version (sonar.java.source): 8
JavaClasspath initialization
JavaClasspath initialization (done) | time=2ms
JavaTestClasspath initialization
JavaTestClasspath initialization (done) | time=61ms
Java Main Files AST scan
1003 source files to be analyzed

404/1003 files analyzed, current file: SOME_CLASS.java
689/1003 files analyzed, current file: SOME_CLASS.java
794/1003 files analyzed, current file: SOME_CLASS.java
1003/1003 source files have been analyzed

> Task :sonarqube
Java Main Files AST scan (done) | time=38737ms
Java Test Files AST scan
250 source files to be analyzed

250/250 source files have been analyzed

> Task :sonarqube
Java Test Files AST scan (done) | time=6597ms
Sensor JavaSquidSensor [java] (done) | time=45427ms
Sensor JaCoCo XML Report Importer [jacoco]
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=413ms
Sensor Kotlin Sensor [kotlin]
26 source files to be analyzed
Sensor Kotlin Sensor [kotlin] (done) | time=272ms

26/26 source files have been analyzed
13/13 source files have been analyzed
2/2 source files have been analyzed

```

As you can see, sonarqube ran many different sensors on that module, including Java and Kotlin sensors.

1. Logs for Kotlin Multiplatform module:

```auto
------------- Run sensors on module MY_KOTLIN_MULTIPLATFORM_MODULE
Sensor JaCoCo XML Report Importer [jacoco]
Report doesn't exist: 'SOME_XML_FILE'
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
Sensor JavaXmlSensor [java]
Sensor JavaXmlSensor [java] (done) | time=0ms

```

As you can see, sonarqube didn’t launch Kotlin sensor on this module, only xml and jacoco.

How can I enforce Sonarqube to run analysis on this module? It just enters the module, and ignore all sources (I tried all combinations of `sonar.sources`, `sonar.java.source`, `sonar.java.binaries`).

Maybe problem is that Sonarqube scanner don’t look at files inside sources dir but only on applied plugins, and it can’t find `java-library` or `com.android.library` plugins, so it skip the analysis?  
Because my module have only these plugins:

```auto
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'

```

---

<div class="post-metadata">

**Author:** ![bukajsytlos](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/bukajsytlos/32/18906_2.png) [@bukajsytlos](https://community.sonarsource.com/u/bukajsytlos)\
**Post date:** [February 3, 2021, 10:43am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/10 "2021-02-03T10:43:23Z")

</div>

You might be correct [sonar-scanner-gradle/SonarQubePlugin.java at 1e71faf88cecc90acf638b968b59926f1ee3cb4c · SonarSource/sonar-scanner-gradle · GitHub](https://github.com/SonarSource/sonar-scanner-gradle/blob/1e71faf88cecc90acf638b968b59926f1ee3cb4c/src/main/java/org/sonarqube/gradle/SonarQubePlugin.java#L98)

---

<div class="post-metadata">

**Author:** ![nilsjr](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nilsjr/32/21791_2.png) [@nilsjr](https://community.sonarsource.com/u/nilsjr)\
**Post date:** [May 3, 2021, 10:04am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/11 "2021-05-03T10:04:14Z")

</div>

Whats the current state of this issue? Is this part of the roadmap due increased importance of KMM projects.

I’ve tried several configurations:  
My module structure:  
/module/src/commonMain  
/module/src/commonTest  
/module/src/androidMain  
/module/src/androidTest

**Plugin configuration:**  
property(“sonar.sources”, buildutils.SonarQubeUtils.sourcePaths)  
property(“sonar.tests”, buildutils.SonarQubeUtils.testPaths)  
property(“sonar.junit.reportPaths”, “$buildDir/test-results/testDebugUnitTest”)

```
object SonarQubeUtils {

  val sourcePaths = listOf(
    "src/commonMain/kotlin",
    "src/androidMain/kotlin",
  ).joinToString(separator = ",")

  val testPaths = listOf(
    "src/commonTest/kotlin",
    "src/androidTest/kotlin",
  ).joinToString(separator = ",")
}

```

then running gradle sonarqube:  
_Resource not found: package.TrackingTest under the directory /XX while reading test reports. Please, make sure your “sonar.junit.reportPaths” property is configured properly_

Whats the problem?  
junit.reportPaths targets /test-results/testDebugUnitTest/TEST-package.TrackingTest.xml but the error message reports test class not found. Above I defined sonar.test with commonTest where the plugin should find the class (src/commonTest/kotlin/package/TrackingTest.kt)

SonarQube plugin version: 3.2.0

---

<div class="post-metadata">

**Author:** ![Margarita\_Nedzelska](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/margarita_nedzelska/32/47493_2.png) [@Margarita\_Nedzelska](https://community.sonarsource.com/u/Margarita_Nedzelska)\
**Post date:** [May 3, 2021, 10:15am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/12 "2021-05-03T10:15:05Z")

</div>

Hello @nilsjr,

Thank you for the message. Unfortunately, currently we’re not supporting Kotlin multiplatform properly. This issue was not in priority for some time, but currently we’re considering to implement the fix. I can’t tell you about the timing, but there is a ticket for it, so you can monitor the progress of this issue.

[https://jira.sonarsource.com/browse/SONARKT-23](https://jira.sonarsource.com/browse/SONARKT-23)

Regards,  
Margarita

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [May 10, 2021, 10:15am UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/13 "2021-05-10T10:15:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Alexandre\_Gigleux](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alexandre_gigleux/32/26_2.png) [@Alexandre\_Gigleux](https://community.sonarsource.com/u/Alexandre_Gigleux)\
**Post date:** [June 14, 2023, 12:18pm UTC](https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849/14 "2023-06-14T12:18:39Z")

</div>

Hello,

We did the required changes. SonarCloud now supports Kotlin Multiplatform: [Kotlin MultiPlaform Support is here!](https://community.sonarsource.com/t/kotlin-multiplaform-support-is-here/92577) and it should work out of the box if you upgrade your Scanner for Gradle version to version 4.2.1.3168

Alex
