如何使用或设置 sonar-project.properties 文件?

How do I use, or set up sonar-project.properties file?

我很少接触 SonarQube,但被要求制作一份文档来解释如何设置/使用 "sonar-project.properties file"。任何信息或输入将不胜感激。

这里有一些资源可以帮助您入门

https://www.wrightfully.com/setting-up-sonar-analysis-for-c-projects/ - 请参阅第 6 步:声纳-project.properties 文件。

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

github上也有一些示例项目,你也可以参考那里的project.properties文件, https://github.com/SonarSource/sonar-scanning-examples

在项目根目录下创建配置文件:

  • sonar-project.properties:
# Must be unique in a given SonarQube instance
sonar.projectKey=my-project

# This is the name and version displayed in the SonarQube UI.
# Was mandatory prior to SonarQube 6.1.
sonar.projectName=My project
sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file.
# Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set. 
sonar.sources=src
 
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

参考: