Analyze multi-module project with multiple languages using Maven

Versions: SonarQube 8.0 (developer), sonar-maven-plugin 3.6.1.1688

I have the following Maven multi module project:

project

  • module-java (java sources)
  • module-cpp (c++ sources)

When calling mvn install on the project the module-cpp is build using MSBuild and the Wrapper (according to the Documentation) which works fine. The wrapper-output is generated to project/module-cpp/sonar.
Now I try to run the sonar-maven-plugin using mvn sonar:sonar -Dsonar.cfamily.build-wrapper-output=module-cpp/sonar on the project which will detect both modules, run the analysis on module-java but fails to detect any sources or the given wrapper-output on module-cpp and does not include any findings.
The analysis succeeds, however there is no traces of module-cpp besides its pom.xml which is being analyzed.

I tried to run the the analysis using the SonarScanner CLI on the module-cpp alone with sonar.cfamily.build-wrapper-output=module-cpp/sonar which worked just as expected and detected sources and published findings to the server.

What am I missing? Anything I could debug?

Hi,

Welcome to the community!

Since you’re using the Maven scanner, you’re getting Maven-centric, and specifically Java-centric behavior. The Scanner for Maven is setting the value of your sonar.sources to the Java sources. To make this work, you’ll need to override that with something like

mvn sonar:sonar -Dsonar.sources=source/main/java,source/main/cpp

Note that you’ll need to do the same for your test files too. You’ll also need to manually specify the paths to your C++ test reports.

 
HTH,
Ann

2 Likes

Hey Ann,

That was actually it, thank you so much.
I simply added <sonar.sources>source/main/cpp</sonar.sources> to the pom.xml of my module-cpp and it worked just as expected when runnung mvn sonar:sonar on my project parent pom.xml.

Again, thanks for saving me from a headache there :slight_smile:

1 Like