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

Jee*_*ham 6 sonar-runner sonarqube sonarqube5.1

SonarQube Server 5.1.2, Sonar-Runner 2.4

正如在Multi-moduleProject中提供的那样,我创建了一个项目结构

Accounts
|
->invoice
  |
   ->src

->receipt
  |
   ->src

->sonar.properties
Run Code Online (Sandbox Code Playgroud)

文件: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
Run Code Online (Sandbox Code Playgroud)

当在sonar-runner中执行上述配置时遇到错误"src"文件夹在"Account"目录中缺失,希望此配置与该链接中可用的conf相同.根据理解,如果配置正常,那么发票和收据将在"帐户项目" 下列为子项目,因此在上述配置中需要进行哪些更改才能在一个项目下实现多个模块/项目.

错误

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.

小智 10

试试这个:

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
Run Code Online (Sandbox Code Playgroud)

  • 根据上面的文档链接,您可以通过在每个模块目录中放置嵌套的“sonar.properties”文件并仅覆盖相关设置来实现类似的效果。 (3认同)