test coverage report not found in ear/pom or projects with no tests

452 views
Skip to first unread message

jeromevdl

unread,
Jun 2, 2017, 3:38:57 AM6/2/17
to SonarQube
Hi,

I'm using sonarqube 6.3.1, maven 3.3.9, plugin maven sonar 3.0.2, cobertura 2.1.1, qualinsight-mojo-cobertura-core plugin 1.1.0, multi module project.

After executing a mvn clean install, reports are well generated in projects that have tests, but there is no report in ear projects for exemple or parent project (pom) and i have the following error when i run  mvn sonar:sonar -Dsonar.coverageReportPaths=target/cobertura/ut/converted-coverage.xml :

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project toto: Error during parsing of coverage report D:\workspace\toto\target\cobertura\ut\converted-coverage.xml: D:\workspace1_todelete\toto\target\cobertura\ut\converted-coverage.xml (Le chemin d'accès spécifié est introuvable

Is there a way to tell sonar not to fail if no report is found ? I think i've seen something like this in a previous version (with generic test coverage).

Thanks !

G. Ann Campbell

unread,
Jun 2, 2017, 9:19:17 AM6/2/17
to SonarQube, jvande...@octo.com
Hi,

We prefer a fail-fast approach so that you know immediately if there's a problem with your configuration, rather than allowing analysis to succeed and leaving you to diagnose backwards why the expected report results aren't reflected in your SonarQube project. Which is a long way of saying: no, there's not a way to silently ignore it when this report is missing.


Ann

Jérôme Van Der Linden

unread,
Jun 2, 2017, 9:26:08 AM6/2/17
to G. Ann Campbell, SonarQube
But in my parent pom, there are no test, it is just a pom. And the build fail because of this. In that case it is not possible to analyze a multi module maven projet, like nearly all maven projects indeed... Am I missing something ?

Jérôme

Julien HENRY

unread,
Jun 6, 2017, 7:53:39 AM6/6/17
to SonarQube, ann.ca...@sonarsource.com, jvande...@octo.com
Hi,

The Cobertura Sensor is not supposed to run on parent module, because it will only run on modules having Java source files:

So I guess your issue is more on the EAR project.

Note that we don't support the Cobertura plugin, but maybe you could create an issue on GitHub.

++

Julien

Jérôme Van Der Linden

unread,
Jun 6, 2017, 8:16:12 AM6/6/17
to Julien HENRY, SonarQube, G. Ann Campbell
I have excluded the ear from the analysis, there is no code to analyse so i don't care. But i cannot exclude the parent pom because no analysis is done in that case. And i have the error on it while it has 'pom' packaging. As i said i use qualinsight-mojo-cobertura-core plugin which convert cobertura report into Sonar report. There is no problem neihter in cobertura nor in this plugin, they don't try something they should not. The problem is on Sonar here, which search a report in a pom project...

Jérôme

Le 6 juin 2017 13:53, "Julien HENRY" <julien...@sonarsource.com> a écrit :
Hi,

The Cobertura Sensor is not supposed to run on parent module, because it will only run on modules having Java source files:

So I guess your issue is more on the EAR project.

Note that we don't support the Cobertura plugin, but maybe you could create an issue on GitHub.

++

Julien


Le vendredi 2 juin 2017 15:26:08 UTC+2, Jérôme Van Der Linden a écrit :
But in my parent pom, there are no test, it is just a pom. And the build fail because of this. In that case it is not possible to analyze a multi module maven projet, like nearly all maven projects indeed... Am I missing something ?

Jérôme
Le 2 juin 2017 15:19, "G. Ann Campbell" <ann.ca...@sonarsource.com> a écrit :
Hi,

We prefer a fail-fast approach so that you know immediately if there's a problem with your configuration, rather than allowing analysis to succeed and leaving you to diagnose backwards why the expected report results aren't reflected in your SonarQube project. Which is a long way of saying: no, there's not a way to silently ignore it when this report is missing.


Ann

On Friday, 2 June 2017 03:38:57 UTC-4, jeromevdl wrote:
Hi,

I'm using sonarqube 6.3.1, maven 3.3.9, plugin maven sonar 3.0.2, cobertura 2.1.1, qualinsight-mojo-cobertura-core plugin1.1.0, multi module project.

Julien HENRY

unread,
Jun 6, 2017, 8:25:10 AM6/6/17
to Jérôme Van Der Linden, SonarQube, G. Ann Campbell
Sorry, I misread your initial message (would have been clearer with a stacktrace or analysis logs ;))

So indeed we are again facing the problem of property inheritance in Maven. Maybe the good trade off would be to not fail when we can't find report AND the current module is not a child module? Or just log a warning and don't fail in all situations? @Ann WDYT?

Julien Henry | SonarSource

Developer

http://sonarsource.com

G. Ann Campbell

unread,
Jun 6, 2017, 8:42:32 AM6/6/17
to Julien HENRY, Jérôme Van Der Linden, SonarQube
Julien,

To hew to the fail-fast philosophy, I think we should restrict it as much as possible, so I'd say don't fail only when: !report && !child


Ann




---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

Jérôme Van Der Linden

unread,
Jun 6, 2017, 8:45:22 AM6/6/17
to G. Ann Campbell, SonarQube, Julien HENRY
Just beware of something. My parent is not really a parent. It is a pom with a list of modules, there is no parent-child relation... 

Jérôme Van Der Linden

Julien HENRY

unread,
Jun 9, 2017, 1:57:17 PM6/9/17
to Jérôme Van Der Linden, G. Ann Campbell, SonarQube
Hi Jérôme,

As long as SonarQube "see" it as a parent, @Ann proposal will be ok. My concern is more for leaf modules (like your EAR). Having to exclude them is not very convenient.

What about using a Maven profile to apply the property conditionally? You would have to put something like this in your parent pom (here I really mean the parent, so that it is inherited by all modules):

<profile>
  <id>generic-coverage</id>
  <activation>
    <file>
      <exists>${project.basedir}/target/coverage.xml</exists>
    </file>
  </activation>
  <properties>
    <sonar.coverageReportPaths>${project.basedir}/target/coverage.xml</sonar.coverageReportPaths>
  </properties>
</profile>

This way the property will only be set on modules having a coverage report.

++

Julien Henry | SonarSource

Developer

http://sonarsource.com


Jerome

unread,
Jun 13, 2017, 3:27:34 AM6/13/17
to SonarQube, ann.ca...@sonarsource.com
Thanks Julien,

That's finally what I did. One sonar profile with sonar config and one sonar-coverage that is activated if the xml report is present.

Regards,

Jérôme
Reply all
Reply to author
Forward
0 new messages