- versions: sonarscanner-for-gradle version 3.3 (also tried 3.1.1 and 3.0), Gradle 6.9, Android plugin 4.2.2
- error:
Unable to find variant '...' to use for SonarQube analysis. Candidates are: ...
1: Unable to find variant 'aaaaa' to use for SonarQube analysis. Candidates are: productionDebug, developmentDebug, productionRelease, developmentRelease
2: Unable to find variant 'developmentDebug' to use for SonarQube analysis. Candidates are: debug, release
3: Unable to find variant 'debug' to use for SonarQube analysis. Candidates are: productionDebug, developmentDebug, productionRelease, developmentRelease
4: Unable to find variant 'development' to use for SonarQube analysis. Candidates are: productionDebug, developmentDebug, productionRelease, developmentRelease
- steps to reproduce:
Run./gradlew sonarqube
on an Android project with multiple flavors, while using the following config:
// root build.gradle
subprojects {
apply plugin: 'org.sonarqube' // this does not seem to make any difference
sonarqube() {
androidVariant "aaaaa"
}
properties {
// ...
}
}
project(":react-native-firebase_app") {
sonarqube {
skipProject = true
}
}
sonarqube() {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "a"
property "sonar.projectKey", "b"
}
}
- potential workaround: don’t specify androidVariant and let the task waste time on duplicate variants you don’t need to check
P.S. Not sure if relevant, but we configure the source folders of all flavors additionally like:
production.res.srcDirs = ['src/production/res']
production.java.srcDirs = ['src/common/java']
- We also use underscores in the names of flavors (I cleaned them up here to make it more readable):
- We use _production and _development (so also _productionDebug and _developmentDebug etc).
- If I omit androidVariant, I get these log messages:
Selected primary task 'sonarqube' from project :
No variant name specified to be used by SonarQube. Default to 'productionDebug'
No variant name specified to be used by SonarQube. Default to 'debug'