logger.info( "configuring report plugin " + plugin.getId() );
MavenSession session = mavenReportExecutorRequest.getMavenSession();
List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories();
PluginDescriptor pluginDescriptor =
mavenPluginManagerHelper.getPluginDescriptor( plugin, remoteRepositories, session );
List<GoalWithConf> goalsWithConfiguration = new ArrayList<GoalWithConf>();
boolean userDefinedReports = true;
if ( reportPlugin.getReportSets().isEmpty() && reportPlugin.getReports().isEmpty() )
{
// by default, use every goal, which will be filtered later to only keep reporting goals
userDefinedReports = false;
List<MojoDescriptor> mojoDescriptors = pluginDescriptor.getMojos();
for ( MojoDescriptor mojoDescriptor : mojoDescriptors )
{
goalsWithConfiguration.add( new GoalWithConf( mojoDescriptor.getGoal(),
mojoDescriptor.getConfiguration() ) );
}
}
else
{
Set<String> goals = new HashSet<String>();
for ( String report : reportPlugin.getReports() )
{
if ( goals.add( report ) )
{
goalsWithConfiguration.add( new GoalWithConf( report, reportPlugin.getConfiguration() ) );
}
else
{
logger.warn( report + " report is declared twice in default reports" );
}
}
for ( ReportSet reportSet : reportPlugin.getReportSets() )
{
goals = new HashSet<String>();
for ( String report : reportSet.getReports() )
{
if ( goals.add( report ) )
{
goalsWithConfiguration.add( new GoalWithConf( report, reportSet.getConfiguration() ) );
}
else
{
logger.warn( report + " report is declared twice in " + reportSet.getId() + " reportSet" );
}
}
}
}
List<MavenReportExecution> reports = new ArrayList<MavenReportExecution>();
for ( GoalWithConf report : goalsWithConfiguration )
{
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( report.getGoal() );
if ( mojoDescriptor == null )
{
throw new MojoNotFoundException( report.getGoal(), pluginDescriptor );
}
MojoExecution mojoExecution = new MojoExecution( plugin, report.getGoal(), "report:" + report.getGoal() );
mojoExecution.setMojoDescriptor( mojoDescriptor );
mavenPluginManagerHelper.setupPluginRealm( pluginDescriptor, mavenReportExecutorRequest.getMavenSession(),
Thread.currentThread().getContextClassLoader(), IMPORTS,
EXCLUDES );
if ( !isMavenReport( mojoExecution, pluginDescriptor ) )
{
if ( userDefinedReports )
{
// reports were explicitly written in the POM
logger.warn( "ignoring " + mojoExecution.getPlugin().getId() + ':' + report.getGoal()
+ " goal since it is not a report: should be removed from reporting configuration in POM" );
}
continue;
}
mojoExecution.setConfiguration( mergeConfiguration( mojoDescriptor.getMojoConfiguration(),
reportPlugin.getConfiguration(),
report.getConfiguration(),
mojoDescriptor.getParameterMap().keySet() ) );
MavenReport mavenReport =
getConfiguredMavenReport( mojoExecution, pluginDescriptor, mavenReportExecutorRequest );
MavenReportExecution mavenReportExecution =
new MavenReportExecution( mojoExecution.getPlugin(), mavenReport, pluginDescriptor.getClassRealm() );
lifecycleExecutor.calculateForkedExecutions( mojoExecution, mavenReportExecutorRequest.getMavenSession() );
if ( !mojoExecution.getForkedExecutions().isEmpty() )
{