How to ask Sonar to analyze only one flavor of my project?

Hello,

I am working on an Android project (Kotlin + Java, gradle).
I have three build types: debug, release , and intune
I have four flavours: prod, dev, uat, and beta
I use Azure DevOps as CI. These are my tasks.

task: Cache@2 // to load gradle libs I used in previous build to reduce build time
task: SonarCloudPrepare@1 // to initialize SonarCloud with projectKey and projectName
task: Gradle@3 // ./gradlew assembleDevDebug -x lint -PversCode=$(BUILD.BUILDNUMBER)
task: Gradle@3 // ./gradlew testDEVINTDebugUnitTest -x lint -PversCode=$(BUILD.BUILDNUMBER)
task: Gradle@3 // ./gradlew jacocoTestReport -x lint -PversCode=$(BUILD.BUILDNUMBER)
task: Gradle@3
displayName: 'Analyze Code Coverage'
inputs:
  options: '-PversCode=$(BUILD.BUILDNUMBER)'
  tasks: 'lint sonar'
  jdkVersionOption: 1.17
  sqAnalysisEnabled: true
  sqGradlePluginVersionChoice: 'build'

The problem is the time it takes to finish ‘Analyze Code Coverage’. It takes around 20 min to finish this task which is a lot. Sometimes CI fails my build because it takes more than an hour to finish the whole build. In this case this particular task is playing a big role.

After I looked at the logs on Azure CI, I noticed that it is running all flavours. That’s why it takes long time.
So, my question is how can I ask sonar to only consider one variant, in my case DevDebug?

I found that I didn’t set androidVariant in my sonar block. My issue resolved after I did that.

sonar {
        androidVariant = "DevDebug
        ...
}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.