Maven multi-module analysis with reactor

Hi community,

I am trying to scan with Sonarqube a multi-module maven project with a structure like this:


 -- pomBom

I am building the project with reactor, launched from an external BOM project that includes all needed configuration, including the sonar properties. So, in my example, pomParent extends pomBom, pom-A and pom-B extends pomParent. And I am doing this from a gitlab pipeline.

In the sonarqube-check job of the pipeline, I do something like this

    - cd bom-project
    - mvn -pl "../parent-project/$SRC_DIR" install -am -Dmaven.test.skip -Dskip.checkstyle 
    - mvn -pl "../parent-project/$SRC_DIR"  verify 
    - cd  "parent-project/$SRC_DIR"
    - mvn  sonar:sonar -Dsonar.projectKey=parent-project-key

where SRC_DIR could be project-A, project-B, etc

The analysis reaches Sonarqube for every sub-project, but the issue is that every project execution overwrites the previous one. Analysis of projectB overwrites analysis of projectA. Sonarqube is not keeping the mutimodule structure, it keeps only one level, instead of two (parent and children).

I have looked in the internet for different solutions, like running sonar:sonar in the BOM folder specifying the sub-project, but did not work. Actually, the available information of how shoud I proceed is not clear for me.

Maven 3.6.3
Sonarqube instance is a corporative one (in the cloud). Not sure of the current version (I can re-check) but for sure is a recent one.

Hope I am clear. Any help is appreciated. Thank you!

Hi @jgarrido,

I see from your sonarqube-check job that you analyze submodule by submodule.
Submodules of a Maven project are not meant to be analyzed as projects. You should analyze the parent project, and SonarQube will handle modules natively.
So, the pipeline should look something like this:

- cd bom-project
- mvn -pl "../parent-project/$SRC_DIR" install -am -Dmaven.test.skip -Dskip.checkstyle 
- mvn -pl "../parent-project/$SRC_DIR"  verify 
- cd  "parent-project"
- mvn  sonar:sonar -Dsonar.projectKey=parent-project-key

All the best,


Hi Irina,

it works! I have added the property “” and it creates the structure properly.

Thanks a lot for your help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.