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
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:
For a regular java module with Android and Kotlin:
------------- 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.
Logs for Kotlin Multiplatform module:
------------- 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:
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)
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.
We did the required changes. SonarCloud now supports Kotlin Multiplatform: Kotlin MultiPlaform Support is here! and it should work out of the box if you upgrade your Scanner for Gradle version to version 4.2.1.3168