使用 SonarQube 进行多模块项目分析

Multi module project analysis with SonarQube

SonarQube Server 5.1.2, Sonar-Runner 2.4

根据 Multi-moduleProject 中的规定,我创建了一个项目结构

Accounts
|
->invoice
  |
   ->src

->receipt
  |
   ->src

->sonar.properties

文件:sonar.properties

sonar.projectKey=org.mycompany.acc
sonar.projectName=Account
sonar.projectVersion=1.0

sonar.sources=src

sonar.modules=invoice,receipt

invoice.sonar.projectName=Invoice
receipt.sonar.projectName=Receipt

当在 sonar-runner 中执行上述配置时,我遇到错误 "src" "Account" 目录中缺少文件夹,希望此配置与 link 中可用的 conf 相同.根据理解,如果配置没问题,那么 Invoice 和 Receipt 将被列为 Account Project 下的 sub project,那么在上面的配置中需要做哪些更改才能实现多模块/项目在一个项目下。

错误

ERROR: Error during Sonar runner execution ERROR: Unable to execute Sonar ERROR: Caused by: The folder 'src' does not exist for 'org.mycompany.acc' (base directory = C:\Users\xyz\Accounts\.) ERROR: ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with t he -e switch. ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

试试这个:

sonar.projectKey=org.mycompany.acc
sonar.projectName=Account
sonar.projectVersion=1.0

sonar.sources=src # try to remove this by the way if you don't have suchdirectory under root folder of project

sonar.modules=invoice,receipt

invoice.sonar.projectName=Invoice
invoice.sonar.sources=invoice/src
receipt.sonar.projectName=Receipt
receipt.sonar.sources=receipt/src

您可以尝试此选项,如果您想同时扫描多个项目或在同一个构建中扫描多个项目,请尝试此选项。

sonar.sources=invoice,receipt