简体   繁体   English

用于多模块项目的声纳插件分析

[英]sonar-eclipse plugin analysis for multi-module project

I have a maven project of the form 我有一个表格的maven项目

<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. 我可以使用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. 项目关键是com.example.project:project我还安装了Eclipse的Sonar插件,并希望使用Eclipse分析我的项目。

My issue is that the Package Explorer in Eclipse shows the modules as projects. 我的问题是Eclipse中的Package Explorer将模块显示为项目。 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. 这意味着当我点击特定项目/模块并执行“配置” - >与Sonar关联时,我无法选择顶级项目(此处标记为“项目”)并且只选择模块。

When I try to input the groupId and artifactId, then those do not match with the sonar project key (com.example.project:project). 当我尝试输入groupId和artifactId时,那些与声纳项目键(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. 我认为如果我可以尝试将顶级项目(groupdId:“com.example.project”,artifactid:“project”)与模块相关联,那将会起作用。

Is there a way of doing that? 有没有办法做到这一点?

I am using Sonar 3.1 and Eclipse Indigo. 我正在使用Sonar 3.1和Eclipse Indigo。

You have to associate every project in Eclipse with the corresponding module in Sonar. 您必须将Eclipse中的每个项目与Sonar中的相应模块相关联。 For instance, in your example, the "module1" Eclipse project should be associated to the "con.example.project:module1" Sonar project. 例如,在您的示例中,“module1”Eclipse项目应与“con.example.project:module1”Sonar项目相关联。

Yeah, Fabrice is absolutely correct. 是的,Fabrice是绝对正确的。 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. 我甚至尝试将Java Nature添加到父级并向其添加Sonar无济于事。

Finally, I went back into one of the modules, selected Configure -> Associate with Sonar. 最后,我回到其中一个模块,选择了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. 在这里,确保在下拉列表中选择了Sonar服务器(在Windows中添加 - >首选项 - >声纳 - >添加...),选中模块旁边的复选框,然后单击在服务器上查找。 This auto-magically populated the GroupIds and ArtifactIds for me. 这为我自动填充了GroupIds和ArtifactIds。 Then just hit Finish and you should be good to go. 然后点击完成,你应该很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM