java - 从 Eclipse 实例运行 Sonar 代码分析

标签 java eclipse maven jenkins sonarqube

我们使用 Jenkins 构建应用程序并通过 Maven 对代码运行 Sonar 分析。

我能够创建本地服务器,并使用 Sonar 运行器运行 Sonar 分析。

我能够将我的 eclipse 实例连接到公司 sonarqube runner 并从 eclipse 的现有分析中获取问题。但是,当从 Eclipse 运行“分析”时,它失败了。

它返回, 您必须为“未知”定义以下强制属性:sonar.sources

当我查看该过程时,我发现临时文件夹中下载了一个临时 Sonar 运行程序,并创建了一个 sonar-project.properties 并使用它运行分析。该属性文件中没有定义 sonar.sources 。由于这个属性文件不在我的控制范围内,如何解决这个问题?

最佳答案

sonar-project.properties 配置文件必须位于 eclispe 项目的根目录中。它应该看起来像这样:

# Required metadata
sonar.projectKey=nutch-key
sonar.projectName=nutch-prj
sonar.projectVersion=1.0
# Path to the parent source code directory.
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on   Windows.
# Since SonarQube 4.2, this property is optional. If not set, SonarQube starts looking for source code
# from the directory containing the sonar-project.properties file.
sonar.sources=src
# Encoding of the source code
sonar.sourceEncoding=UTF-8
# Additional parameters
sonar.my.property=value

关于java - 从 Eclipse 实例运行 Sonar 代码分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31762959/

相关文章:

java - 列表迭代java中的FreeMarker算术运算

java - 如何从 Eclipse 中的根目录 "classes"和 "test-classes"文件夹中过滤文件?

maven - Intellij 中不存在错误包,但在 Spring Tool Suite STS 中工作

java - Android 蓝牙发送/接收 HashMap

java - 添加ReSTLet 2.3 CORS的正确方法

java - Tfs checkout 和映射问题

maven - Dropwizard从0.7升级到0.8.0发布错误

java - 从maven导入自己的项目时出错

java - 编程语言运行时使用堆栈的主要原因是什么?

android - 如何在 Eclipse 中使用来自 PhoneGap Build 和 PhoneGap Android 项目的相同源代码