为多模块项目设置Sonar Runner + cobertura

时间:2017-07-10 15:48:53

标签: java maven sonarqube cobertura maven-cobertura-plugin

我的项目结构

App XYX
   +- pom.xml
   +-SubfOlder
   +- Module 1
      +- pom.xml 
   +- Module 2
      +- pom.xml 
   +- Module3
      +- pom.xml 
   +- Module4
      +- pom.xml
   .......
   .......
   +- Module10
      +- pom.xml

我目前正在使用声纳扫描仪v2.5.1作为Jenkins后期构建任务。我不知道如何为我的所有10个模块定义sonar.sources。

我通过文档:https://docs.sonarqube.org/display/SCAN/Advanced+SonarQube+Scanner+Usages 但我不想一个接一个地定义所有10个模块。如果有50多个模块也是如此。

任何建议如何处理这种情况。谢谢。

2 个答案:

答案 0 :(得分:1)

使用maven sonar:sonar目标。如果已经设置了maven,那么使用sonar-project.properties比使用*更方便。

答案 1 :(得分:1)

不幸的是,属性中的sonar.sources无法识别通配符,因此您唯一能做的就是手动列出所有通配符,逗号分隔。我遇到了这个问题,并且有大约20个单独的项目要写入属性行。以下是我的属性的样子:

sonar.projectKey=xyz
sonar.projectName=xyz
sonar.sources=${WORKSPACE}/client-xyz/,${WORKSPACE}/client-yzx/,${WORKSPACE}/server-xyz/,${WORKSPACE}/server-yzx/,${WORKSPACE}/common-xyz/,${WORKSPACE}/common-yzx/,${WORKSPACE}/zxy-adapter-mq,${WORKSPACE}/zxy-api-yzx,${WORKSPACE}/zxy-common-yzx,${WORKSPACE}/zxy-file-base,${WORKSPACE}/zxy-file-yzx,${WORKSPACE}/zxy-init-yzx,${WORKSPACE}/zxy-jms-yzx,${WORKSPACE}/zxy-messaging-api,${WORKSPACE}/zxy-messaging-in-yzx,${WORKSPACE}/zxy-messaging-out-yzx,${WORKSPACE}/zxy-ws-gen-yzx,${WORKSPACE}/zxy-ws-in-yzx
sonar.java.binaries=**/target/*
sonar.tests=${WORKSPACE}/test-yzx/
sonar.dynamicAnalysis=reuseReports
sonar.core.codeCoveragePlugin=cobertura
sonar.java.coveragePlugin=cobertura
sonar.verbose=false
sonar.showProfiling=true
sonar.ws.timeout=180
sonar.junit.reportPaths=${WORKSPACE}/test-yzx/junit/
sonar.cobertura.reportPath=${WORKSPACE}/test-yzx/cobertura/coverage.xml
sonar.cobertura.utReportPath=${WORKSPACE}/test-yzx/cobertura/coverage.xml
sonar.java.cobertura.reportPath=${WORKSPACE}/test-yzx/cobertura/coverage.xml
sonar.java.coverage.reportPaths=${WORKSPACE}/test-yzx/cobertura/
sonar.coverage.dtdVerification=false
sonar.scm.disabled=true
相关问题