适用于 Android 的多模块项目的 SonarQube [英] SonarQube for multi module project for Android

查看:59
本文介绍了适用于 Android 的多模块项目的 SonarQube的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我浏览过很多文章和帖子,但遗憾的是,我似乎没有一篇清楚.我想为我的 android 项目集成 sonarqube.我的项目结构如下:

I have been through many articles and posts and sadly not a single one seems clear to me. I want to integrate sonarqube for my android project. The structure of my project is as below:

最初,我按照此处提到的方式设置了一个 sonarqube.gradle:配置带有子模块的 Android 项目以与 sonarqube gradle 插件一起使用的正确方法是什么?

Initially, I had setup a single sonarqube.gradle the way it is mentioned here:What is the correct way to configure an Android project with submodules for use with the sonarqube gradle plugin?

但它为我做的是用它处理的最后一个模块覆盖数据.这意味着我在 sonarqube 登录中仅看到域的代码行.如果我不添加 apply from: '../sonarqube.gradle'在域中然后我可以看到数据库的代码.如果我没有在数据库和域中添加 apply from: '../sonarqube.gradle' ,那么我会看到它的数据.所以我认为它会覆盖日志.

But what it is doing for me is overwriting the data with the last module it processed. Which means I see code line in sonarqube login for only domain. If I do not add apply from: '../sonarqube.gradle' in domain then I can see code for database. If I do not add apply from: '../sonarqube.gradle' in database and domain then I see it for data. So I am thinking its overwriting the logs.

有人可以帮助我了解在 Android 中为多模块项目设置 sonarqube 的正确方法是什么?

Can someone help me to understand what is the right way to setup sonarqube for multimodule project in Android?

 apply plugin: "org.sonarqube"

sonarqube {
  properties {
      property "sonar.projectName", "my-app"
      property "sonar.projectKey", "my-app"
      property "sonar.host.url", "URL"
      property "sonar.sources", "./src/main/"
      property "sonar.sourceEncoding", "UTF-8"
      property "sonar.language", "kotlin"
      property "sonar.login", "token"
      property "sonar.projectVersion", "1.0"
      property "sonar.analysis.mode", "publish"
      property "sonar.android.lint.report", "./build/outputs/lint-results-debug.xml"
      property "sonar.exclusions", "**/BuildConfig.class,**/R.java,**/R$*.java,src/main/gen/**/*,src/main/assets/**/*"
  }
}

推荐答案

移除 projectKey 属性,只在根 build.gradle 中声明:

Remove the projectKey property and declare it only inside the root build.gradle:

 apply plugin: "org.sonarqube"

sonarqube {
  properties {
      property "sonar.projectName", "my-app"
      property "sonar.host.url", "URL"
      property "sonar.sources", "./src/main/"
      property "sonar.sourceEncoding", "UTF-8"
      property "sonar.language", "kotlin"
      property "sonar.login", "token"
      property "sonar.projectVersion", "1.0"
      property "sonar.analysis.mode", "publish"
      property "sonar.android.lint.report", "./build/outputs/lint-results-debug.xml"
      property "sonar.exclusions", "**/BuildConfig.class,**/R.java,**/R$*.java,src/main/gen/**/*,src/main/assets/**/*"
  }
}

这篇关于适用于 Android 的多模块项目的 SonarQube的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆