On Maven builds can sonar:sonar be run in parallel?

Sonar is being integrated into our multi-module maven build via Jacoca.

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.8.5</version>
</plugin>

I noticed that the sonar:sonar step adds an extra build stage with the same name as my top level pom.xml. e.g.

Building my-project 1.0.1 [1/14]
.
.
. 
Building my-project 1.0.1 [15/14] 

Which overrides the default project name. That hides the sonar build time while giving the impression it occurs first.

The plugin also seems to save all the sonar analysis until the end. Is there any option to run the analysis in parallel? i.e. As soon as a module is built kick of its analysis while the subsequent modules are being built?

The goal here would be to reduce the overall time spent building. I’ve a 15 minute build, of which sonar takes 2 minutes. Given past experience with other tools that’s actually quick. But none the less it’d be better if it could be reduced further.

The Sonar plugin needs to be able to process all of the build artifacts, including the unit test results, which can only be done after all of the other build steps are complete. It cannot run in parallel with any typical build step.

1 Like

This sounds like the authoritative answer. But I’m curious, in a Maven multi-module project each module builds and runs its own unit tests. Once a module is finished building would sonar not be able to analysis it? i.e. While the remaining modules continuing to build.

Also I’m curious if you’ve any insight into

Building my-project 1.0.1 [15/14] 

I had hoped that changing sonar.projectName to a name other than the top level pom.xml would fix the issue. But it made no difference.

For clarity this means the top level module reports the sonar build time. e.g.

[2023-01-06T17:00:17.831Z] [INFO] ------------------------------------------------------------------------
[2023-01-06T17:00:17.831Z] [INFO] Reactor Summary for my-project 1.0.1:
[2023-01-06T17:00:17.831Z] [INFO] 
[2023-01-06T17:00:17.831Z] [INFO] my-project ............................................ SUCCESS [01:52 min]
[2023-01-06T17:00:17.831Z] [INFO] my-project-common ..................................... SUCCESS [ 22.046 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-migration .................................. SUCCESS [  3.998 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-test-common ................................ SUCCESS [ 33.710 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-dto ........................................ SUCCESS [  3.010 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-producer ................................... SUCCESS [ 31.773 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-db ......................................... SUCCESS [01:07 min]
[2023-01-06T17:00:17.831Z] [INFO] my-project-utils ...................................... SUCCESS [ 23.637 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-server ..................................... SUCCESS [05:50 min]
[2023-01-06T17:00:17.831Z] [INFO] my-project-client ..................................... SUCCESS [ 32.758 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-http-client ................................ SUCCESS [  5.322 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-integration ................................ SUCCESS [02:43 min]
[2023-01-06T17:00:17.831Z] [INFO] jacoco-coverage-report ................................ SUCCESS [  8.389 s]
[2023-01-06T17:00:17.831Z] [INFO] my-project-other ...................................... SUCCESS [01:00 min]
[2023-01-06T17:00:17.831Z] [INFO] ------------------------------------------------------------------------
[2023-01-06T17:00:17.831Z] [INFO] BUILD SUCCESS
[2023-01-06T17:00:17.831Z] [INFO] ------------------------------------------------------------------------
[2023-01-06T17:00:17.831Z] [INFO] Total time:  15:22 min
[2023-01-06T17:00:17.831Z] [INFO] Finished at: 2023-01-06T17:00:17Z
[2023-01-06T17:00:17.831Z] [INFO] ------------------------------------------------------------------------

I’d prefer a dedicate entry at the end as this seems hackish.

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