简体   繁体   English

SonarQube 用于 Android 的多模块项目

[英]SonarQube for multi module project for Android

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.我想为我的 android 项目集成 sonarqube。 The structure of my project is as below:我的项目结构如下:

在此处输入图像描述

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? 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?

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.这意味着我在 sonarqube 中看到代码行仅用于域登录。 If I do not add apply from: '../sonarqube.gradle' in domain then I can see code for database.如果我没有在域中添加apply from: '../sonarqube.gradle'那么我可以看到数据库的代码。 If I do not add apply from: '../sonarqube.gradle' in database and domain then I see it for data.如果我没有在数据库和域中添加apply from: '../sonarqube.gradle'那么我会看到它的数据。 So I am thinking its overwriting the logs.所以我认为它会覆盖日志。

Can someone help me to understand what is the right way to setup sonarqube for multimodule project in Android?有人可以帮助我了解在 Android 中为多模块项目设置 sonarqube 的正确方法是什么?

 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/**/*"
  }
}

Remove the projectKey property and declare it only inside the root build.gradle:删除 projectKey 属性并仅在根 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/**/*"
  }
}

Analyzing Multi-Project Builds分析多项目构建

Off doc link https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/关闭文档链接https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/

// build.gradle in:app
sonarqube {
    properties {
         property "sonar.*", "{value}"
    }
}

// build.gradle in :feature-module
subprojects {
    sonarqube {
        properties {
            property "sonar.*", "{value}"
        }
    }
}

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

相关问题 如何在多模块 android 项目(kotlin + java)上配置 SonarQube(使用 jacoco)? - How to configure SonarQube (with jacoco) on multi module android project (kotlin + java)? 无法在我的多模块Gradle项目中获取声纳索引文件索引 - Not able to get sonarqube to index files in my multi module gradle project 多模块项目中的Android NavigationDrawer - Android NavigationDrawer in multi module project 多模块项目中的android样式 - android styles in a multi module project 多模块Android Project Gradle建议 - Multi Module Android Project Gradle suggestion 未解决的参考:Android 多模块项目中的 buildFeatures - Unresolved reference: buildFeatures in Android multi module project Android多模块项目因TypeNotPresentException失败 - Android multi-module project fails with TypeNotPresentException Android Hilt - 多模块项目转换错误 - Android Hilt - multi module project cast error 使用Gradle为多模块项目设置SonarQube 5.4:无法通过ClassLoader访问类XYZ - Set up SonarQube 5.4 for multi-module project with Gradle: Class XYZ is not accessible through the ClassLoader 将多模块Android Intellij Project移植到Android Studio - porting multi-module Android Intellij Project to Android Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM