cynepnaxa cynepnaxa - 20 days ago 5
Java Question

Sonar: "Module is already part of project" or How to upload projects with same dependencies?

I have two projects (A and B), which use the same reusable module (C). I upload A into sonarqube without problems, but when I upload 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 into sonarqube.

Answer

I just had this problem as well. If you are running 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 run Sonar on project A, run it normally (no --projects switch). When you run Sonar on project B, supply an exclusion list (with the --projects switch).

For Project A:

mvn sonar:sonar

then

mvn sonar:sonar --projects !moduleC

This method is mentioned briefly here:

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