Skip to content

Commit c282961

Browse files
Albert MeltzerAlbert Meltzer
Albert Meltzer
authored and
Albert Meltzer
committed
Report mojo: find a top level module for "mvn -pl"
1 parent 47849fd commit c282961

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/main/java/org/scoverage/plugin/SCoverageReportMojo.java

+30
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,36 @@ else if ( !module.getPackaging().equals( "pom" ) )
479479
}
480480
}
481481

482+
if (null == topLevelModule)
483+
{
484+
for ( MavenProject module : reactorProjects )
485+
{
486+
if ( !module.hasParent() )
487+
{
488+
continue;
489+
}
490+
491+
MavenProject parent = module.getParent();
492+
while ( parent.hasParent() )
493+
{
494+
parent = parent.getParent();
495+
}
496+
if ( null != topLevelModule )
497+
{
498+
if (topLevelModule.getBasedir().getAbsolutePath().length()
499+
< parent.getBasedir().getAbsolutePath().length())
500+
{
501+
continue;
502+
}
503+
}
504+
topLevelModule = parent;
505+
}
506+
if ( null == topLevelModule )
507+
{
508+
topLevelModule = project;
509+
}
510+
}
511+
482512
/* Empty report must be generated or top-level site will contain invalid link to non-existent Scoverage report
483513
if ( scoverageDataDirs.isEmpty() )
484514
{

0 commit comments

Comments
 (0)