in src/main/java/org/apache/maven/reporting/exec/DefaultMavenReportExecutor.java [269:367]
private MavenReportExecution prepareReportExecution(
MavenReportExecutorRequest mavenReportExecutorRequest, GoalWithConf report, boolean userDefined)
throws Exception {
ReportPlugin reportPlugin = report.getReportPlugin();
PluginDescriptor pluginDescriptor = report.getPluginDescriptor();
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(report.getGoal());
if (mojoDescriptor == null) {
throw new MojoNotFoundException(report.getGoal(), pluginDescriptor);
}
MavenProject project = mavenReportExecutorRequest.getProject();
if (!userDefined && mojoDescriptor.isAggregator() && !canAggregate(project)) {
// aggregator mojos automatically added from plugin are only run at execution root
return null;
}
MojoExecution mojoExecution = new MojoExecution(
pluginDescriptor.getPlugin(), report.getGoal(), mavenReportExecutorRequest.getExecutionId());
mojoExecution.setMojoDescriptor(mojoDescriptor);
mavenPluginManagerHelper.setupPluginRealm(
pluginDescriptor,
mavenReportExecutorRequest.getMavenSession(),
Thread.currentThread().getContextClassLoader(),
IMPORTS,
EXCLUDES);
if (!isMavenReport(mojoExecution, pluginDescriptor)) {
if (userDefined) {
// reports were explicitly written in the POM
LOGGER.warn(
"Ignoring {}:{}"
+ " goal since it is not a report: should be removed from reporting configuration in POM",
mojoExecution.getPlugin().getId(),
report.getGoal());
} else {
LOGGER.debug(
"Ignoring {}:{} goal since it is not a report",
mojoExecution.getPlugin().getId(),
report.getGoal());
}
return null;
}
Xpp3Dom pluginMgmtConfiguration = null;
if (project.getBuild() != null && project.getBuild().getPluginManagement() != null) {
Plugin pluginMgmt =
find(reportPlugin, project.getBuild().getPluginManagement().getPlugins());
if (pluginMgmt != null) {
pluginMgmtConfiguration = (Xpp3Dom) pluginMgmt.getConfiguration();
}
}
mojoExecution.setConfiguration(mergeConfiguration(
mojoDescriptor.getMojoConfiguration(),
pluginMgmtConfiguration,
reportPlugin.getConfiguration(),
report.getConfiguration(),
mojoDescriptor.getParameterMap().keySet()));
MavenReport mavenReport = getConfiguredMavenReport(mojoExecution, pluginDescriptor, mavenReportExecutorRequest);
MavenReportExecution mavenReportExecution = new MavenReportExecution(
report.getGoal(),
mojoExecution.getPlugin(),
mavenReport,
pluginDescriptor.getClassRealm(),
userDefined);
lifecycleExecutor.calculateForkedExecutions(mojoExecution, mavenReportExecutorRequest.getMavenSession());
if (!mojoExecution.getForkedExecutions().isEmpty()) {
String reportDescription = pluginDescriptor.getArtifactId() + ":" + report.getGoal() + " report";
String execution;
if (StringUtils.isNotEmpty(mojoDescriptor.getExecutePhase())) {
// forked phase
execution = "'"
+ (StringUtils.isEmpty(mojoDescriptor.getExecuteLifecycle())
? ""
: ('[' + mojoDescriptor.getExecuteLifecycle() + ']'))
+ mojoDescriptor.getExecutePhase() + "' forked phase execution";
} else {
// forked goal
execution = "'" + mojoDescriptor.getExecuteGoal() + "' forked goal execution";
}
LOGGER.info("Preparing {} requires {}", reportDescription, execution);
lifecycleExecutor.executeForkedExecutions(mojoExecution, mavenReportExecutorRequest.getMavenSession());
LOGGER.info("{} for {} preparation done", execution, reportDescription);
}
return mavenReportExecution;
}