Reputation: 310
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
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
Upvotes: 7
Views: 2790
Reputation: 1020
With the current version of sonarqube gradle plugin you must not use sonarqube {}
, but sonar {}
to configure the android variant.
See example below:
plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id "org.sonarqube" version "3.5.0.2730"
}
project(":app") {
sonar {
androidVariant 'betaDeveloperDebug'}
}
Upvotes: 1
Reputation: 1
Add this to the project level build gradle. You can run specified build variant like this.
project(":your_module") {
sonarqube {
androidVariant 'your_variant'}
}
Upvotes: 0
Reputation: 748
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
Also, to learn about adding sonarqube to multi-module projects: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
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.
Upvotes: 6