mavensonarqubesonar-maven-plugin

Sonar maven plugin: same project key for all modules does not work?


I am using sonar-maven-plugin 3.2 and maven 3.3.9. In the parent POM, I have the sonar.projectKey maven property defined. The value is in effect, I can see it from the printout of sonar. But the mvn sonar:sonar step fails, because the maven modules use the same project key value, because the maven property has the same value in all modules. Sonar gives the error:

Project '...' can't have 2 modules with the following key: ...

Is there really no way to have a single sonar project that contains all maven modules? Are all modules must be really different sonar projects?

I am aware that I could use the branch property asa hack, but I would like to avoid doing that. If there is a way to have a maven multi module project in sonar with a single project key, containing all maven modules, that would be the best...


Solution

  • According to SonarQube Analysis Parameters:

    sonar.projectKey

    The project key that is unique for each project. Allowed characters are: letters, numbers, '-', '_', '.' and ':', with at least one non-digit.
    When using Maven, it is automatically set to <groupId>:<artifactId>.

    Therefore, remove your sonar.projectKey configuration and it should work.

    (I have been through the same loop).