java SonarQube Findbugs“需要编译源”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25367243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SonarQube Findbugs "needs sources to be compiled"
提问by Kory
I am trying to get SonarQube findbugs working, but when I try to run it I get the error: "Findbugs needs sources to be compiled. Please build project before executing sonar and check the location of compiled classes."
我试图让 SonarQube findbugs 工作,但是当我尝试运行它时,我收到错误:“Findbugs 需要编译源。请在执行声纳之前构建项目并检查编译类的位置。”
sonar.sources is set to a folder with all of my src files and sonar.binaries is set to a folder with all of my class and jar files. This layout works with findbugs for one of my projects, but on the other I get the above error.
sonar.sources 设置为包含我所有 src 文件的文件夹,而 sonar.binaries 设置为包含我所有类和 jar 文件的文件夹。此布局适用于我的一个项目的 findbugs,但在另一个项目中出现上述错误。
This is the debug error provided when FindBugs will not run: http://pastie.org/9483921
这是 FindBugs 无法运行时提供的调试错误:http: //pastie.org/9483921
How can I fix this, and is there a certain folder FindBugs needs classes/jars in to work?
我该如何解决这个问题,是否有某个文件夹 FindBugs 需要类/jars 才能工作?
Thanks.
谢谢。
采纳答案by other name
Add property
添加属性
sonar.binaries=${workspace}/proy/build/
To Sonar Configuration. If you ar using several proyects to build, use coma separed.
到声纳配置。如果您使用多个项目来构建,请使用 coma separed。
回答by Anthony E.
SonarQube requires source code to be built before it analyzes it. This is going to differ depending on how you are building it, but check here and click on your building platform.
SonarQube 要求在分析之前构建源代码。这将根据您的构建方式而有所不同,但请在此处查看并单击您的构建平台。
For example: If you were using SonarQube to analyze a project with Maven, you must issue the following commands in this order (assuming you followed the steps according to this maven configuration page, which is linked as an option in the first link):
例如:如果您使用 SonarQube 使用 Maven 分析项目,则必须按此顺序发出以下命令(假设您按照此 Maven 配置页面执行步骤,该页面在第一个链接中作为选项链接):
mvn clean install
mvn sonar:sonar
Thus, you must build the code before any sonar analysis can be done. Also note, you must issue these commands separately and you should wait for the install to finish completely before running sonar.
因此,您必须在进行任何声纳分析之前构建代码。另请注意,您必须单独发出这些命令,并且在运行声纳之前应该等待安装完全完成。
回答by Kraal
I've faced the same issue in the past.
我过去遇到过同样的问题。
Check that you don't have a folder somewhere under the src/main folder containing only a pkg-info.java
file. These files are javadoc files and are thus not compiled. However, the folder is created in target/classes, findbugs detects it but finds no .class
which causes a crash with the “needs sources to be compiled” message.
检查您在 src/main 文件夹下的某处没有仅包含pkg-info.java
文件的文件夹。这些文件是 javadoc 文件,因此不会被编译。但是,该文件夹是在目标/类中创建的,findbugs 检测到它但没有找到.class
,这会导致崩溃并显示“需要编译源”消息。
The solution is to remove the folder with the pkg-info.java
file or add real java sources files in it (which will be compiled and make findubgs happy.)
解决方案是删除包含该pkg-info.java
文件的文件夹或在其中添加真正的 java 源文件(这将被编译并使 findubgs 满意。)
回答by Kevin Sarabi
If you do not want to compile and use sonar-runner as before , you can create a folder and put a valid java class there and execute as below:
如果你不想像以前那样编译和使用 sonar-runner,你可以创建一个文件夹并将一个有效的 java 类放在那里并执行如下:
sonar-runner -Dsonar.java.binaries=folder path
回答by Erd
sonar property names have changed, see http://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
声纳属性名称已更改,请参阅http://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
e.g. sonar.java.binaries replaces sonar.binaries for plugin version > 2.5
例如 sonar.java.binaries 替换插件版本的 sonar.binaries > 2.5
This fixed my findbugs issue.
这解决了我的 findbugs 问题。