scoverage/scoverage-maven-plugin

NPE during report aggregation when multiple modules are specified using -pl arg

sumeetgajjar opened this issue · 1 comments

Hi,

Consider the following multi-module maven project.

  • Parent
    • child1
    • child2
      • GrandChild1
      • GrandChild2
    • child3

On running mvn -pl child1,child2/GrandChild1 clean scoverage:report -e, the command fails with the following null pointer exception:

[INFO] Reactor Summary:
[INFO]
[INFO] child1 1.0-SNAPSHOT ................................ SUCCESS [  7.912 s]
[INFO] child3 1.0-SNAPSHOT ................................ FAILURE [  5.126 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.185 s
[INFO] Finished at: 2022-02-02T21:57:03-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.scoverage:scoverage-maven-plugin:1.4.11:report (default-cli) on project child3: An error has occurred in SCoverage report generation: Report generation exception: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.scoverage:scoverage-maven-plugin:1.4.11:report (default-cli) on project child3: An error has occurred in SCoverage report generation: Report generation exception
.
.
.
Caused by: java.lang.NullPointerException
    at org.scoverage.plugin.SCoverageReportMojo.rebase (SCoverageReportMojo.java:560)
    at org.scoverage.plugin.SCoverageReportMojo.generateAggregatedReports (SCoverageReportMojo.java:506)
    at org.scoverage.plugin.SCoverageReportMojo.generate (SCoverageReportMojo.java:230)
    at org.scoverage.plugin.SCoverageReportMojo.execute (SCoverageReportMojo.java:385)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

This is because neither child1 nor child3 returns true for module.isExecutionRoot() and thus topLevelModule is always null.

MavenProject topLevelModule = null;
for ( MavenProject module : reactorProjects )
{
if ( module.isExecutionRoot() )
{
topLevelModule = module;
}

seems related to #93