SonarScan skips some module in my Android Gradle project

Must-share information (formatted with Markdown):

  • SonarQube Gradle plugin version 3.2.0
  • SonarQube scan all of my code base
  • Some modules in my code base are skipped

This is my root’s Gradle script

sonarqube {
    properties {
        property("sonar.projectName", "app-android")
        property("sonar.projectKey", "app-android")
        property("sonar.exclusions", "**/res/**/*.xml,**/*Test*/**,*.json,**/*test*/**,**/.gradle/**,**/R.class")
    }
}

A tried dumpToFile and noticed some sonar.sources configs are empty

## Generated by a SonarScanner
#Tue May 18 14:47:26 ICT 2021
\:features.\:features\:login_v2.sonar.java.jdkHome=/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home
\:features.\:features\:login_v2.sonar.java.source=1.8
\:features.\:features\:login_v2.sonar.java.target=1.8
\:features.\:features\:login_v2.sonar.moduleKey=app-android\:features\:login_v2
\:features.\:features\:login_v2.sonar.projectBaseDir=/Users/ltpquang/Projects/app-android/ProxCute/features/login_v2
\:features.\:features\:login_v2.sonar.projectName=login_v2
\:features.\:features\:login_v2.sonar.projectVersion=unspecified
\:features.\:features\:login_v2.sonar.sources=
sonar.exclusions=**/res/**/*.xml,**/*Test*/**,*.json,**/*test*/**,**/.gradle/**,**/R.class
sonar.host.url=https\://sonar.ProxCute.vn
sonar.log.level=TRACE
sonar.login=56f9b33a118064e0409ac3464341e8347b178609
sonar.modules=\:app,\:common,\:features,\:libraries,\:ProxCute.mock
sonar.projectBaseDir=/Users/ltpquang/Projects/app-android/ProxCute
sonar.projectKey=app-android
sonar.projectName=app-android
sonar.projectVersion=unspecified
sonar.scanner.app=ScannerGradle
sonar.scanner.appVersion=3.2.0/Gradle 6.7.1
sonar.scanner.dumpToFile=./sonar.properties
sonar.sourceEncoding=UTF-8
sonar.sources=
sonar.verbose=true
sonar.working.directory=/Users/ltpquang/Projects/app-android/ProxCute/build/sonar

The directory structures are the same for all modules. What’s wrong? Any rule in source detecting might I’ve missed?

After a bit invetigation, these following are properties than the Scanner plugin cannot automatically detect for skipped modules

sonar.binaries
sonar.java.binaries
sonar.java.libraries
sonar.java.test.binaries
sonar.java.test.libraries
sonar.libraries
sonar.sources
sonar.tests

Anyone know how are those properties get resolved?

Hi,

Welcome to the community!

I’m not super familiar with Gradle, but I’md wondering if this docs section on multi-project builds is relevant.

 
Ann

Thanks for keeping in touch. Unfortunately multi-project is not my problem. The root cause is that current Sonar Gradle plugin havent support Android’s dynamic feature modules yet. I’m working on PR to improve this, and will get back to update on this topic later.

1 Like

This problem has been resolved in SonarQube Gradle plugin version 3.3 fyi

1 Like

@ltpquang I have a multi module set up in my android project. And one of them has a feature module nested as well. I am using the latest version of sonarqube(3.3) as well. But I see the extension applied to the feature module, but the sonarqube task is not configured and available.

The way our CI workflows work, I need to be able to run the tests/coverage on each of the modules(including the feature modules) separately and hence I am stuck with the sonar gradle plugin not working in this case.

My project structure:

  • repo-root
    • app-module (works)
      • feature-module (DOES NOT work)
    • networking-module (works)
    • domain-module (works)

I tried applying the sonarqube plugin directly from the root gradle script and individually on each of the module’s gradle. Makes no difference.

Any suggestions/tips? Thanks in advance.