Class DefaultMavenReportExecutor

java.lang.Object
org.apache.maven.reporting.exec.DefaultMavenReportExecutor
All Implemented Interfaces:
MavenReportExecutor

@Singleton @Named public class DefaultMavenReportExecutor extends Object implements MavenReportExecutor

This component will build some MavenReportExecution from MavenReportExecutorRequest. If a MavenReport needs to fork a lifecycle, this fork is executed here. It will ask the core to get some informations in order to correctly setup MavenReport.

Note if no version is defined in the report plugin, the version will be searched with resolvePluginVersion(...) method:

  1. use the one defined in the reportPlugin configuration,
  2. search similar (same groupId and artifactId) plugin in the build/plugins section of the pom,
  3. search similar (same groupId and artifactId) plugin in the build/pluginManagement section of the pom,
  4. ask PluginVersionResolver to get a fallback version (display a warning as it's not a recommended use).

Following steps are done:

  • get PluginDescriptor from the MavenPluginManager (through MavenPluginManagerHelper.getPluginDescriptor(...) to protect from core API change)
  • setup a ClassLoader, with the Site plugin classloader as parent for the report execution.
    Notice that some classes are imported from the current Site plugin ClassRealm: see IMPORTS. Corresponding artifacts are excluded from the artifact resolution: doxia-site-renderer, doxia-sink-api  and maven-reporting-api.
    Work is done using MavenPluginManager (through MavenPluginManagerHelper.setupPluginRealm(...) to protect from core API change)
  • setup the mojo using MavenPluginManager.getConfiguredMojo(...)
  • verify with LifecycleExecutor.calculateForkedExecutions(...) if any forked execution is needed: if yes, execute the forked execution here
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • mavenPluginManager

      private final org.apache.maven.plugin.MavenPluginManager mavenPluginManager
    • mavenPluginManagerHelper

      private final MavenPluginManagerHelper mavenPluginManagerHelper
    • lifecycleExecutor

      private final org.apache.maven.lifecycle.LifecycleExecutor lifecycleExecutor
    • pluginVersionResolver

      private final org.apache.maven.plugin.version.PluginVersionResolver pluginVersionResolver
    • IMPORTS

      private static final List<String> IMPORTS
    • EXCLUDES

      private static final List<String> EXCLUDES
  • Constructor Details

    • DefaultMavenReportExecutor

      @Inject public DefaultMavenReportExecutor(org.apache.maven.plugin.MavenPluginManager mavenPluginManager, MavenPluginManagerHelper mavenPluginManagerHelper, org.apache.maven.lifecycle.LifecycleExecutor lifecycleExecutor, org.apache.maven.plugin.version.PluginVersionResolver pluginVersionResolver)
  • Method Details

    • buildMavenReports

      public List<MavenReportExecution> buildMavenReports(MavenReportExecutorRequest mavenReportExecutorRequest) throws org.apache.maven.plugin.MojoExecutionException
      Description copied from interface: MavenReportExecutor
      Build the MavenReports, with associated forked executions if necessary.
      Specified by:
      buildMavenReports in interface MavenReportExecutor
      Parameters:
      mavenReportExecutorRequest - the request
      Returns:
      a list or prepared Maven report executions
      Throws:
      org.apache.maven.plugin.MojoExecutionException - on report execution issue
    • buildReportPlugin

      protected List<MavenReportExecution> buildReportPlugin(MavenReportExecutorRequest mavenReportExecutorRequest, ReportPlugin reportPlugin) throws Exception
      Throws:
      Exception
    • prepareGoals

      private boolean prepareGoals(ReportPlugin reportPlugin, org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, List<DefaultMavenReportExecutor.GoalWithConf> goalsWithConfiguration)
    • prepareReportExecution

      private MavenReportExecution prepareReportExecution(MavenReportExecutorRequest mavenReportExecutorRequest, DefaultMavenReportExecutor.GoalWithConf report, boolean userDefined) throws Exception
      Throws:
      Exception
    • canAggregate

      private boolean canAggregate(org.apache.maven.project.MavenProject project)
    • getConfiguredMavenReport

      private org.apache.maven.reporting.MavenReport getConfiguredMavenReport(org.apache.maven.plugin.MojoExecution mojoExecution, org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, MavenReportExecutorRequest mavenReportExecutorRequest) throws org.apache.maven.plugin.PluginContainerException, org.apache.maven.plugin.PluginConfigurationException
      Throws:
      org.apache.maven.plugin.PluginContainerException
      org.apache.maven.plugin.PluginConfigurationException
    • isMavenReport

      private boolean isMavenReport(org.apache.maven.plugin.MojoExecution mojoExecution, org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
    • mergeConfiguration

      private org.codehaus.plexus.util.xml.Xpp3Dom mergeConfiguration(org.codehaus.plexus.configuration.PlexusConfiguration mojoConf, org.codehaus.plexus.util.xml.Xpp3Dom pluginMgmtConfig, org.codehaus.plexus.configuration.PlexusConfiguration pluginConf, org.codehaus.plexus.configuration.PlexusConfiguration reportSetConf, Set<String> parameters)
      Merge plugin configuration and reportset configuration to mojo configuration to get effective mojo configuration.
      Parameters:
      mojoConf - configuration done at mojo descriptor level
      pluginMgmtConfig - configuration done at build.pluginManagement level
      pluginConf - configuration done at reporting plugin level
      reportSetConf - configuration done at reportSet level
      parameters - set of supported parameters: any other parameter will be removed
      Returns:
      the effective configuration to be used
    • convert

      private org.codehaus.plexus.util.xml.Xpp3Dom convert(org.codehaus.plexus.configuration.PlexusConfiguration config)
    • resolvePluginVersion

      protected String resolvePluginVersion(ReportPlugin reportPlugin, MavenReportExecutorRequest mavenReportExecutorRequest) throws org.apache.maven.plugin.version.PluginVersionResolutionException
      Resolve report plugin version. Steps to find a plugin version stop after each step if a non null value has been found:
      1. use the one defined in the reportPlugin configuration,
      2. search similar (same groupId and artifactId) mojo in the build/plugins section of the pom,
      3. search similar (same groupId and artifactId) mojo in the build/pluginManagement section of the pom,
      4. ask PluginVersionResolver to get a fallback version and display a warning as it's not a recommended use.
      Parameters:
      reportPlugin - the report plugin to resolve the version
      mavenReportExecutorRequest - the current report execution context
      Returns:
      the report plugin version
      Throws:
      org.apache.maven.plugin.version.PluginVersionResolutionException - on plugin version resolution issue
    • find

      private org.apache.maven.model.Plugin find(ReportPlugin reportPlugin, List<org.apache.maven.model.Plugin> plugins)
      Search similar (same groupId and artifactId) plugin as a given report plugin.
      Parameters:
      reportPlugin - the report plugin to search for a similar plugin
      plugins - the candidate plugins
      Returns:
      the first similar plugin
    • mergePluginToReportPlugin

      private void mergePluginToReportPlugin(MavenReportExecutorRequest mavenReportExecutorRequest, org.apache.maven.model.Plugin buildPlugin, ReportPlugin reportPlugin)
      TODO other stuff to merge ?

      this method will "merge" some part of the plugin declaration existing in the build section to the fake plugin build for report execution:

      • dependencies

      The plugin could only be present in the dependency management section.
      Parameters:
      mavenReportExecutorRequest -
      buildPlugin -
      reportPlugin -