Sonarqube run for specific product flavor and build type (gradle plugin- bug)

Continuing the discussion from Sonarqube run for specific product flavor and build type (gradle plugin):

Currently we are having problems running sonarqube for just a specific build variant. for example clienttestDebug

Our structure is like this. We have 3 different build types

  • Release
  • Debug
  • Profile

And has many (over 30) product flavors. For instance

 productFlavors {
        dev {
            
        }

        demo {

        }

        clienttest {

        }
        ...
     }

So we don’t want to run the sonar to run for all variants. Normally there is a way documented as below

sonarqube {
    androidVariant 'clienttestDebug'
}

However the piece above doesn’t work as expected and tries to run for all the variants. Is there something thats missing. We’re using sonarqube plugin version 2.7

I have found out that this issue is due to addition of plugin from root build.grade.

To learn more about the gradle plugins you can read: https://docs.gradle.org/current/userguide/plugins.html#sec:old_plugin_application

You have to make the addition of the plugin in your root build.gradle as follows;

plugins {
  id "org.sonarqube" version "2.8"
}
subprojects {
    apply plugin: 'org.sonarqube'
    sonarqube {
        androidVariant "clienttestDebug"
    }
}

Hope this helps.

2 Likes