Maven Sonar Plugin integration with Maven Build Cache

Greetings,

We are currently using the Maven Sonar scanner plugin to perform automated scanning of our multi-module Java project. We run a single analysis from the parent project and everything works well.

In order to speed up our builds, we are also integrating the Maven build cache. However, this causes the Maven Sonar Scanner plugin to fail with this error, since there aren’t necessarily compiled classes for every module.

We are asking for the team to take a look at upgrading the Maven Sonar scanner plugin to support integration with the Maven build cache extension.

Have others experienced this issue? If so, are there clever ways to configure the Maven Sonar scanner plugin to only discover and analyze the modules which have compiled code available? Thanks!

3 Likes

Hi @thisdudeiknew, thanks for reaching out and suggesting this enhancement.

We’ll be working on upgrading the Maven Sonar scanner to Maven 4 soon, and we’ll also discuss the support for Maven build cache. I’ll update this thread as soon as more details are available and the MMF is defined.

Cheers

Hello @thisdudeiknew,

Thanks for your message. We will see what we can do with the issue. Here is the ticket to track the progress:

https://sonarsource.atlassian.net/browse/MSONAR-196

Regards,
Margarita

1 Like

Hi, any update on this? It’s blocking our migration to maven build cache extension.

1 Like

Someone have tried this?
https://groups.google.com/g/jacoco/c/elsmi9_sWbM/m/B-p6d2s8AQAJ

Just to follow up on including the test coverage as part of the cached artifact. It looks like it’s indeed possible by configuring attachedOutputs for the maven-build cache extension configuration. For instance, this seems to work for me:

<configuration>
  <enabled>true</enabled>
  <hashAlgorithm>XX</hashAlgorithm>
  <remote enabled="true" id="xxx">
    <url>xxx</url>
  </remote>
  <attachedOutputs>
    <dirNames>
      <dirName>site/jacoco</dirName>
    </dirNames>
  </attachedOutputs>
</configuration>