声纳:"模块已经是项目的一部分"或如何上传具有相同依赖项的项目?

时间:2014-08-26 08:06:29

标签: java maven sonarqube

我有两个项目(A和B),它们使用相同的可重用模块(C)。我上传A到sonarqube没有问题,但是当我上传B时,声纳-maven-plugin告诉我模块C已经是项目A的一部分。我该如何修复它?我希望将我的两个项目上传到sonarqube。

3 个答案:

答案 0 :(得分:5)

  • If you´re Sonar admin go to http:///background_tasks and select excecution log. You have the following error:
2016.11.18 08:56:08 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task XXXXXX
org.sonar.api.utils.MessageException: Validation of project failed:
  o Module "moduleA" is already part of project "org.company:proj2"
  • So you have to edit the MODULE pom.xml in your project proj1, and say it to Sonar that this module will be named as:
<properties>
    <sonar.moduleKey>org.company:proj2:moduleA-NEW</sonar.moduleKey>
</properties>

答案 1 :(得分:4)

我也遇到了这个问题。如果您运行的是较新版本的Maven,则可以排除模块。这对你来说可能是也可能不是一个充分的答案,但它适合我。

在项目A上运行Sonar时,正常运行(没有--projects开关)。 在项目B上运行Sonar时,请提供排除列表(使用--projects开关)。

对于项目A:

mvn sonar:sonar

然后

mvn sonar:sonar --projects !moduleC

此处简要提及此方法:

http://docs.sonarqube.org/display/SONAR/Analyzing+with+Maven#AnalyzingwithMaven-ExcludingamodulefromSonarQubeanalysis

答案 2 :(得分:-1)

我找到了另一种从分析中排除模块的方法。我们用它,工作正常。这很简单。

  1. 由于模块重复,无法自动创建新项目。所以马上创造它。以admin身份登录Web界面。然后使用设置 - &gt; 供应 - &gt;创建
  2. 打开已创建的项目。然后配置 - &gt;设置 - &gt;排除 - &gt;文件 - &gt;模块排除。