简体   繁体   English

Sonarqube 针对特定产品风格和构建类型运行(gradle 插件)

[英]Sonarqube run for specific product flavor and build type (gradle plugin)

Currently we are having problems running sonarqube for just a specific build variant.目前,我们仅针对特定构建变体运行 sonarqube 时遇到问题。 for example clienttestDebug例如clienttestDebug

Our structure is like this.我们的结构是这样的。 We have 3 different build types我们有 3 种不同的构建类型

  • Release发布
  • Debug调试
  • Profile轮廓

And has many (over 30) product flavors.并且有许多(超过 30 种)产品口味。 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我们正在使用 sonarqube 插件版本 2.7

I have found out that this issue is due to addition of plugin from root build.grade.我发现这个问题是由于从 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要了解有关 gradle 插件的更多信息,您可以阅读: 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/另外,要了解如何将 sonarqube 添加到多模块项目: https://docs.sonarqube.org/latest/gradle/analysis/scan/sonarscanner-for-

You have to make the addition of the plugin in your root build.gradle as follows;您必须在根 build.gradle 中添加插件,如下所示;

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

Hope this helps.希望这可以帮助。

Add this to the project level build.gradle. You can run specified build variant like this.将其添加到项目级别 build.gradle。您可以像这样运行指定的构建变体。

project(":your_module") {
sonarqube {
    androidVariant 'your_variant'}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM