Skip to content

Commit

Permalink
Report mojo: find a top level module for "mvn -pl"
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Meltzer authored and Albert Meltzer committed May 4, 2021
1 parent 47849fd commit c282961
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/org/scoverage/plugin/SCoverageReportMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,36 @@ else if ( !module.getPackaging().equals( "pom" ) )
}
}

if (null == topLevelModule)
{
for ( MavenProject module : reactorProjects )
{
if ( !module.hasParent() )
{
continue;
}

MavenProject parent = module.getParent();
while ( parent.hasParent() )
{
parent = parent.getParent();
}
if ( null != topLevelModule )
{
if (topLevelModule.getBasedir().getAbsolutePath().length()
< parent.getBasedir().getAbsolutePath().length())
{
continue;
}
}
topLevelModule = parent;
}
if ( null == topLevelModule )
{
topLevelModule = project;
}
}

/* Empty report must be generated or top-level site will contain invalid link to non-existent Scoverage report
if ( scoverageDataDirs.isEmpty() )
{
Expand Down

0 comments on commit c282961

Please sign in to comment.