SonarCloud missing files from Gradle multi-project build

  • ALM: Bitbucket Cloud

  • CI system used: Circle CI, but this is not related to that

  • Scanner: Gradle plugin “org.sonarqube” version “”

  • Languages: Kotlin

  • Error observed:

In an otherwise working Gradle multi-project build for a Kotlin Android app, the SonarCloud page that lists the project’s files only includes the base app’s files and none from the sub-projects, meaning we can’t see coverage of the sub-project files.

Can anyone suggest how I can determine why the files are not being included in the analysis?

Detailed Config Info:

The build consists of 3 projects, managed as git submodules (each in its own repo):

  • app
  • uicommon
  • platform-sdk

The builds executes as expected in Android Studio and on the command line; unit and android tests run in all three projects; lint & code coverage output .xml files are generated for each of the three modules.

But when the “sonar” Gradle task is run, only the files in the base ‘app’ are shown on the SonarCloud files page for the project.

I’ve looked at multiple claimed solutions on the web, including Sonarsource’s own github examples, and none cause the files of all projects to be included in the analysis:

Attempt 1: SonarScanner for Gradle
Attempt 2: How to setup sonar for multi-module gradle project
Attempt 3: sonar-scanning-examples/sonarqube-scanner-gradle/gradle-multimodule-coverage at master · SonarSource/sonar-scanning-examples · GitHub
Attempt 4: gradle - SonarQube for multi module project for Android - Stack Overflow
Attempt 5: sonar-scanning-examples/sonarqube-scanner-gradle/gradle-multimodule at master · SonarSource/sonar-scanning-examples · GitHub

File settings.gradle includes:

include ':app'
include ':uicommon'
include ':platform-sdk'

The root build.gradle file contains:

plugins {
    id "org.sonarqube" version ""

sonar {
    properties {
        property "", ""
        property "sonar.projectName", "Android App"
        property "sonar.projectKey", "android_app"
        property "sonar.organization", "XXXX"

The app’s build.gradle file contains:

apply plugin: "org.sonarqube"
sonar {
    properties {
        property "sonar.sources", "src/main/"
        property "sonar.exclusions", ["src/main/res/**/*", "src/debug/"]
        property "sonar.tests", ["src/androidTest/", "src/test/"]

And the uicommon and platform-sdk build.gradle files contain:

apply plugin: "org.sonarqube"
sonar {
    properties {
        property "sonar.sources", "src/main/"
        property "sonar.exclusions", "src/main/res/**/*"
        property "sonar.tests", ["src/androidTest/", "src/test/"]

The SonarCloud “Code” tab only lists app/src at the top level, and within that folder we see the expected files in the base app (the tests are identified, the debug and res files are correctly excluded):

                                      Lines Of Code
app/src                                       8,084

androidTest/java/com/...                          —
main                                          8,084
test/java/com/...                                 —

But none of the files in the uicommon or platform-sdk directories are shown.

After running the Gradle sonar command, I see the three projects listed in the build/sonar directory, which suggests it is aware of all three projects:

%> ls -1 build/sonar

Adding sonar.scm.exclusions.disabled=true makes the sub-projects appear, but this is very suspicious because the sub-projects don’t have .gitignore files, and the main app’s .gitignore file doesn’t use any negated rules, so I personally think there is a bug in SonarCloud.

1 Like

Hi @CWolf ,

Thank you for reaching out! I’ll send you a DM to get more details.


Have you figured this out? It seems that we have the same problem but even sonar.scm.exclusions.disabled=true didn’t change anything. We have only source codes from one module that’s main app and one other module, but next like 20 modules are missing.

HI @wojta,

Welcome to the community!

Please create a new thread with all your details.


Hi, have you been able to resolve this issue? Could you share the solution? I seem to have the same problem with my gradle multi-project build. The analysis only covers the root folders files.

Hi @intershopper,

Please create a new thread with all your details.