Sonar: "The module is already part of the project" or "How to download projects with the same dependencies"?

I have two projects (A and B) that use the same reuse module (C). I load A into sonarqube without any problems, but when I load B, the sonar-maven plugin tells me that module C is already part of project A. How can I fix it? I want both of my projects to be uploaded to sonarqube.

+5
source share
4 answers

I had this problem. If you are using a newer version of Maven, you can exclude modules. This may or may not be a sufficient answer for you, but it was for me.

When you start Sonar in project A, run it in normal mode (no -projects switch). When you run Sonar in project B, put an exception list (with the --projects switch).

For project A:

mvn sonar:sonar 

then

 mvn sonar:sonar --projects !moduleC 

This method is briefly mentioned here:

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

+3
source
  • If you are a Sonar administrator, go to http: /// background_tasks and select the execution log. You have the following error:
 2016.11.18 08:56:08 ERROR [ossctCeWorkerCallableImpl] 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 should edit MODULE pom.xml in your proj1 project and tell Sonar that this module will be called as:
 <properties> <sonar.moduleKey>org.company:proj2:moduleA-NEW</sonar.moduleKey> </properties> 
+4
source

Sonar module name created from maven

 <maven groupId>:<maven artifactId>:<branch name> 

In some cases, they may have the same values ​​for different applications.

In this case, the sonar will be confused, and rightly so.

The solution in this case is to use Matthias Burney's solution with

 <properties> <sonar.moduleKey>groupId:artifactId:some distinct identifier</sonar.moduleKey> </properties> 

However, a better way to do this would be to have different combinations of groupId-artifactId for different applications.

+1
source

I found another way to exclude the module from the analysis. We use it, it works great. It is very simple.

  • A new project cannot be created automatically due to duplication of the module. Therefore, create it manually. Log in to the web interface as an administrator. Then use Settings β†’ Provisioning β†’ Create.
  • Open the created project. Then Configuration β†’ Settings β†’ Exceptions β†’ Files β†’ Module Exclusions.
-1
source

Source: https://habr.com/ru/post/1201134/


All Articles