我设置了根据此示例https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/android/android-sonarqube-scanner向SonarQube发送报告的项目。
我的项目有几个模块:
结果,SonarQube中有2个项目(每个模块)。
是否可以将这两个模块中的报告数据合并到一个SonarQube项目中?
module1设置示例:
sonarqube {
properties {
property "sonar.projectName", "Module1"
property "sonar.projectKey", "module1"
property "sonar.java.binaries", "./build/intermediates/classes/staging/debug"
property "sonar.junit.reportsPath", "./build/test-results/testDebugUnitTest"
property "sonar.jacoco.reportPaths", "./build/jacoco/testDebugUnitTest.exec"
property "sonar.android.lint.report", "./build/reports/lint-results.xml"
def sonarLibraries = configurations.compile.join(",")
property 'sonar.java.libraries', sonarLibraries
property "sonar.host.url", "localhost"
property "sonar.login", "token"
property "sonar.scm.provider", "git"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "./src/main"
property "sonar.tests", "./src/test/java"
property "sonar.exclusions", "build/**,**/*.png,**/*.jpg,**/*.gif"
property "sonar.import_unknown_files", true
property "sonar.dynamicAnalysis", "reuseReports"
}
}
答案 0 :(得分:1)
确定。我知道该怎么做。
我从模块的gradle文件中删除了所有声纳设置和插件,并将其放到根build.gradle
。
注意模块的名称以:
开头。没有它,声纳不会将我的settig应用于模块。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//...
}
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.projectName", "MultiModuleProject"
property "sonar.projectKey", "mmp"
property "sonar.modules", ":module1,:module2"
property ":module1.sonar.java.binaries", "..."
property ":module1.sonar.junit.reportsPath", "..."
property ":module1.sonar.jacoco.reportPaths", "..."
property ":module1.sonar.android.lint.report", "..."
property ":module1.sonar.sources", "./src/main"
property ":module1.sonar.tests", "./src/test/java"
property ":module2.sonar.java.binaries", "..."
property ":module2.sonar.junit.reportsPath", "..."
property ":module2.sonar.jacoco.reportPaths", "..."
property ":module2.sonar.android.lint.report", "..."
property ":module2.sonar.sources", "./src/main"
property ":module2.sonar.tests", "./src/test/java"
//----
property "sonar.host.url", "host"
property "sonar.login", "..."
property "sonar.sourceEncoding", "UTF-8"
}
}