How to integrate sonarqube with KotlinMultiplatform project?

Hello,

I was trying to integrate sonarqube with Kotlin Multiplatform App.
My KMP app has shared module - , Android and swift source code for iOS App.

Any guidance will be appreciated.

Hi,

Welcome to the community!

Take a look at SonarScanner for Gradle, and be aware that you’ll probably need to override sonar.sources to include your Swift code.

 
HTH,
Ann

Thanks Ann for the reply.

Any example will be a great help.

Here the main concern is my KMP project contains both android and iOS source code.

subprojects {
    sonar {
        properties {
            property "sonar.sources", "android/src"
            property "sonar.sources", "common/src"
            **/// here iOS code folder to define ??**
        }
    }
}

Hi,

Per the docs, sonar.sources accepts a comma-delimited list.

So I suppose it would look like this:

subprojects {
    sonar {
        properties {
            property "sonar.sources", "android/src,common/src,ios/src,..."
        }
    }
}

 
HTH,
Ann

Thanks Ann,

Will try and let you know.

1 Like

I’m in a similar situation, having a KMP project that’s targeting both iOS and Android platforms, and for which I’m trying to get Sonarqube to examine out code. Our project’s code is here.

The problem I’m hitting is that, when running the command line to validate things:

$ ./gradlew sonarqube --info

it always fails with:

> Task :sonarqube FAILED
0 files ignored because of inclusion/exclusion patterns
0 files ignored because of scm ignore settings
Loading plugins for detected languages
Load/download plugins
Load/download plugins (done) | time=6ms
Load project repositories
Load project repositories (done) | time=636ms
Indexing files...
Project configuration:
  Excluded sources: **/build-wrapper-dump.json
Indexing files of module 'androidVariant'
  Base dir: /Users/mcpierce/Repositories/variant/androidVariant
  Source paths: src/main/AndroidManifest.xml, src/main/java, src/main/res
  Test paths: src/androidTest/java
  Excluded sources: **/build-wrapper-dump.json
Indexing files of module 'shared'
  Base dir: /Users/mcpierce/Repositories/variant/shared
  Source paths: src/androidMain/kotlin, src/commonMain/kotlin, src/iosMain/ko...
  Test paths: src/androidUnitTest/kotlin, src/commonTest/kotlin, src/iosTest/...
  Excluded sources: **/build-wrapper-dump.json
Indexing files of module 'variant'
  Base dir: /Users/mcpierce/Repositories/variant
  Source paths: androidVariant/src, shared/src, build.gradle.kts, androidVari...
  Excluded sources: **/build-wrapper-dump.json

0 problems were found storing the configuration cache.

But it doesn’t say why it’s failing. Any ideas for how we can fix this?

Hi @mcpierce,

I think you’re going to have to go for the nuclear option with --debug logging instead of --info.

If you still need advice once you find the source of the error, please create a new thread.

 
Thx,
Ann