jnc_sf
jnc_sf

Reputation: 33

sonar-eclipse plugin analysis for multi-module project

I have a maven project of the form

<project>
      <groupId>com.example.project</groupid>
      <artifactId>project</artifactId>
      <module>module1</module>
      <module>module2</module>
      <module>module3</module>
</project>

I am able to run Sonar analysis using maven. The project key is com.example.project:project I have also installed the Sonar plugin for Eclipse and would like to analyze my project using Eclipse.

My issue is that the Package Explorer in Eclipse shows the modules as projects. This means that when I click on a particular project/module and perform "Configure" -> Associate with Sonar, I do not get the option to pick the top level project (here labelled "project") and only the modules.

When I try to input the groupId and artifactId, then those do not match with the sonar project key (com.example.project:project). I think what would work is if I can try to associate the top level project (groupdId: "com.example.project" , artifactid: "project") as opposed to the modules.

Is there a way of doing that?

I am using Sonar 3.1 and Eclipse Indigo.

Upvotes: 3

Views: 1963

Answers (2)

lessonz
lessonz

Reputation: 148

Yeah, Fabrice is absolutely correct. I'm not sure if I did something incorrectly the first time, but I was originally unable to get it to work even as he instructed. I even tried adding the Java Nature to the parent and adding Sonar to it to no avail.

Finally, I went back into one of the modules, selected Configure -> Associate with Sonar. Here, make sure your Sonar server is selected in the drop down (added in Windows -> Preferences -> Sonar -> Add...), check the boxes next to your module(s), and click Find on server. This auto-magically populated the GroupIds and ArtifactIds for me. Then just hit Finish and you should be good to go.

Upvotes: 0

You have to associate every project in Eclipse with the corresponding module in Sonar. For instance, in your example, the "module1" Eclipse project should be associated to the "con.example.project:module1" Sonar project.

Upvotes: 1

Related Questions