Apache Maven 报告执行器

通过MavenReportExecutor ( implementation )准备使用 Maven 3 执行报告插件的类。

与 Maven 2.x 不同:

  1. 报告<version>显式定义是可选的:
    如果没有为报告插件指定版本,则版本由
    1. 在 pom 的build/plugins部分中搜索插件,
    2. 在 pom 的build/pluginManagement部分中搜索插件,
    3. 要求PluginVersionResolver获取回退版本并显示警告,因为它不推荐使用,
  2. 来自build/pluginManagement的插件配置被注入到报告/插件中(从 Maven Reporting Executor 1.2 开始,由 Maven Site Plugin 3.4 使用)。

关于现已过时的报告插件格式的通知

从 1.4 开始(由 Maven Site Plugin 3.7 使用),请求可以(并且应该)从pom 的<reporting.plugins>部分填充,作为${project.reporting.plugins}默认值注入 Mojo 参数:

    @Parameter( defaultValue = "${project.reporting.plugins}", readonly = true )
    private org.apache.maven.model.ReportPlugin[] reportingPlugins;

本节保留解释该组件的先前版本中发生的情况,但在发现主要限制后,该方法迄今已被放弃:有关更多详细信息,请参阅Maven Site Plugin 3.9.0 文档

报告插件可以在maven-site-plugin的<configuration>元素或任何其他报告构建插件中配置,其 XML 模型对应于插件的List< ReportPlugin > 参数:

<reportPlugins>
  <reportPlugin>
    <groupId/>
    <artifactId/>
    <version/>
    <configuration/>
    <reports/>
    <reportSets>
      <reportSet>
        <id/>
        <configuration/>
        <reports/>
      </reportSet>
    </reportSets>
  </reportPlugin>
</reportPlugins>

请注意,这是 POM <reporting>部分中插件的模型:

  • 没有<inherited>元素:此级别不支持报告插件配置继承(请参阅MSITE-484),
  • 在<reportSet>之外添加了额外的<reports>列表,可在通常情况下简化报告配置。

Maven 3 核心通过ReportingConverter组件将<reporting> POM 部分(支持配置继承)自动转换为maven-site-pluginreportPlugins配置。

但是 Maven 3 并没有为任何其他想要使用报告的插件做同样的工作,例如maven-pdf-plugin:这是让 Maven 团队放弃这种方法的关键限制之一。