Reputation: 389
We have a project, with many modules (java and android). We have one additional module which is Kotlin Multiplatform module. We reuse code from this module with our iOS app. Our long term goal is to move more code from existing modules to Kotlin Multiplatform module, to share our core business logic. We use SonarQube for static code analysis. We have our own instance, version 7.9.3 LTS. For scanning our project we use SonarQube Gradle plugin. Additionally we have Jacoco for code coverage.
When scanning our project, SonarQube scanner goes inside our Kotlin Multiplatform module, but don’t find any sources. Simply it says no sources found and it moves to next module. We already posted a problem on sonar source community website, but we didn’t get any response: https://community.sonarsource.com/t/does-sonarcloud-support-kotlin-multiplatform/9849
./gradlew jacocoTestReport sonarqube --info
------------- Run sensors on module [OUR JAVA MODULE]
Delphi Project Helper creation!!!
No exclude directories found in project configuration.
Delphi sensor DelphiSensor...
Delphi Project Helper creation!!!
No exclude directories found in project configuration.
Delphi sensor describe...
SurefireSensor sensor describe...
PMD sensor.describe
Sensor JavaSquidSensor [java]
Configured Java source version (sonar.java.source): 8
JavaClasspath initialization
JavaClasspath initialization (done) | time=1ms
JavaTestClasspath initialization
JavaTestClasspath initialization (done) | time=22ms
Java Main Files AST scan
1003 source files to be analyzed
527/1003 files analyzed, current file: [...]
789/1003 files analyzed, current file: [...]
1003/1003 source files have been analyzed
Java Main Files AST scan (done) | time=29234ms
Java Test Files AST scan
250 source files to be analyzed
250/250 source files have been analyzed
Java Test Files AST scan (done) | time=5492ms
Sensor JavaSquidSensor [java] (done) | time=34763ms
Sensor SurefireSensor [java]
parsing [.../build/test-results/test]
Sensor SurefireSensor [java] (done) | time=202ms
Sensor JaCoCoSensor [java]
Both 'sonar.jacoco.reportPath' and 'sonar.coverage.jacoco.xmlReportPaths' were set. 'sonar.jacoco.reportPath' is deprecated therefore, only 'sonar.coverage.jacoco.xmlReportPaths' will be taken into account.
Both 'sonar.jacoco.reportPaths' and 'sonar.coverage.jacoco.xmlReportPaths' were set. 'sonar.jacoco.reportPaths' is deprecated therefore, only 'sonar.coverage.jacoco.xmlReportPaths' will be taken into account.
Sensor JaCoCoSensor [java] (done) | time=0ms
Sensor JavaXmlSensor [java]
Sensor JavaXmlSensor [java] (done) | time=6ms
Sensor HTML [web]
Sensor HTML [web] (done) | time=2ms
Sensor CheckstyleSensor [checkstyle]
Checkstyle output report: .../checkstyle-result.xml
Checkstyle configuration: .../checkstyle.xml
Checkstyle charset: UTF-8
Sensor CheckstyleSensor [checkstyle] (done) | time=3392ms
Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerConfigurationLoaderSensor
Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerConfigurationLoaderSensor (done) | time=1ms
Sensor JaCoCo XML Report Importer [jacoco]
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=245ms
Sensor Kotlin Sensor [kotlin]
42 source files to be analyzed
Sensor Kotlin Sensor [kotlin] (done) | time=180ms
Sensor DetektSensor [detekt]
42/42 source files have been analyzed
13/13 source files have been analyzed
2/2 source files have been analyzed
0/0 source files have been analyzed
RuleSet: complexity - 6
RuleSet: empty-blocks - 4
RuleSet: formatting - 104
RuleSet: naming - 1
RuleSet: style - 50
Sensor DetektSensor [detekt] (done) | time=1203ms
------------- Run sensors on module [OUR KOTLIN MULTIPLATFORM MODULE]
Delphi Project Helper creation!!!
No exclude directories found in project configuration.
Delphi sensor DelphiSensor...
Delphi Project Helper creation!!!
No exclude directories found in project configuration.
Delphi sensor describe...
SurefireSensor sensor describe...
PMD sensor.describe
Sensor JavaXmlSensor [java]
Sensor JavaXmlSensor [java] (done) | time=0ms
Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerConfigurationLoaderSensor
Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerConfigurationLoaderSensor (done) | time=1ms
Sensor JaCoCo XML Report Importer [jacoco]
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
The strange thing is that it ran some sensors, but not all, it didn’t run Kotlin and Detekt sensors. This is why it didn’t found any sources to scan. Over last few months I spent few days trying different SonarQube configurations for that module. I set all possible SonarQube properties for it with different variations. It's always the same, scanner can detect the module, but after going inside it never run Kotlin sensor and it can't find any Kotlin classes inside.
Our Kotlin Multiplatform projects is a default one, we have following source sets:
Upvotes: 6
Views: 1250
Reputation: 91
A new update was just released.
Starting with v4.2.1.3168, Sonar's Gradle plugin supports KMM projects.
Release announcement on this link: https://community.sonarsource.com/t/kotlin-multiplatform-support-is-here/92577
Upvotes: 1