Sonar-maven-plugin maven resume issue

On the company we have a build that takes >~ 1:30 hours and sometimes it fails due to timeouts. So what we do is use the maven -rf, --resume-from to build again and continue starting from the last module that failed. The problem is using that it is giving this error:

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project och-batch-app: Maven session does not declare a top level project -> [Help 1]

For what I can see in the code on this line sonar-scanner-maven/ at master · SonarSource/sonar-scanner-maven · GitHub the session doesn’t have this root project that is built first when using the -rf argument.

I’m not familiar with maven plugin developement, but shouldn’t another method on the session be used?, seems a common scenario.
I can provide more information if needed.

1 Like

Hi @flenzi

Sorry for the late reply. The scanner for Maven is simply collecting configuration from Maven model. It is an aggregator plugin, that only run on the root module. The concept of root module is in fact not well defined in Maven, because when using advanced reactor options, you may ends up with a forest of modules (and so multiple “roots”).

If you build is so long and fragile, I advice you to use a two steps analysis:

  • mvn verify (and resume it if you need)
  • mvn sonar:sonar

Hope that helps