5
votes

In a Java project, I'm using Sonar with Maven and it's work fine with "sonar way" profile. But when switching to the "Sonar way with Findbugs" profile, it fails :

"Can not execute Sonar: Can not execute Findbugs: Findbugs needs sources to be compiled. Please build project before executing sonar and check the location of compiled classes."

The project is correctly build before the execution of Sonar. But the root module / project doesn't contains any classes. So target/classes is empty

My project is composed of several modules and a root pom.xml

Project

|_ Module 1

|_ Module 2

|_ Module 3

pom.xml

Sonar is running fine for every modules and try to analyze the root project but this one doesn't contains any classes so it fails.

Is there a way to exclude the root project / module (exclude root module is not possible) or tell sonar to only generate a warning in this case or another solution?

Thanks in advance.

1
What command do you run? "mvn clean install sonar:sonar" or "mvn clean install" and then "mvn sonar:sonar"?David RACODON - QA Consultant
David, I'm using Jenkins. I do a clean install followed by a sonar analysys after the build keeping the default options.Cotcho
I tried a simple "mvn clean install" followed by "mvn sonar:sonar" : same problem...Cotcho
Is it specific to this project? Could you run the analysis of the following project sample by following the README file: github.com/SonarSource/sonar-examples/tree/master/projects/… ?David RACODON - QA Consultant
David, no problem running this one...Cotcho

1 Answers

0
votes

I assume you are not facing a sonar or findbugs problem, but you probably have a maven specific problem, e.g. a problem with your multi module pom - you actually even stated it "target/classes is empty". Focus on that before focusing on sonar or findbugs. As a workaround, try setting up a jenkins build for a specific module first. When this is properly built with class files in your target folder, add a sonar goal to your jenkins project and I'd expect it to work.

p.s.: Compare: Maven sonar findbugs fails with no source to compile