用法

该插件用于创建变更报告、JIRA 报告和公告文本文件。它还可以通过电子邮件发送通知。

如何生成更改报告

为了使用这个目标,只需在src/changes/目录中创建一个changes.xml文件。这是一个典型的changes.xml示例,显示了语法:

<document xmlns="http://maven.apache.org/changes/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
  <properties>
    <title>Changes Tester Project</title>
    <author email="jruiz@exist.com">Johnny R. Ruiz III</author>
  </properties>
  <body>
    <release version="1.1" date="2005-03-01" description="Subsequent release">
      <action dev="jruiz" type="add">
        Added additional documentation on how to configure the plugin.
      </action>
      <action dev="aramirez" type="fix" issue="MPJIRA-11">
        Enable retrieving component-specific issues.
      </action>
      <action dev="jruiz" type="remove" due-to="Allan Ramirez" due-to-email="aramirez@exist.com">
        The element type " link " must be terminated by the matching end-tag.
        Deleted the erroneous code.
      </action>
    </release>

    <release version="1.0" date="2005-01-01" description="First release">
      <action dev="jruiz" type="update">
        Uploaded documentation on how to use the plugin.
      </action>
    </release>
  </body>
</document>

有关<release><action>元素及其属性的详细信息,请参阅更改参考。

要生成更改报告,请将更改插件插入项目pom.xml的<reporting>部分

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <version>2.5</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>changes-report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

并执行站点阶段以生成报告。

mvn site

链接到您的问题管理系统

如果您在changes.xml文件中使用问题属性并在pom.xml中配置了<issueManagement>元素,则报告将包含指向问题管理系统中问题的链接。

从 2.4 版开始,该插件针对一大堆不同的问题管理系统进行了预配置。你所要做的就是在你的 POM 中输入你的问题管理系统和它的 URL。它看起来像这样:

<project>
  ...
  <issueManagement>
    <system>JIRA</system>
    <url>http://jira.company.com/</url>
  </issueManagement>
  ...
</project>

如果您在 POM 中有以前的<issueLinkTemplatePerSystem>配置,那么当您开始使用 2.4 版时,您可能会丢弃它,除非您使用多个问题管理系统。

下表显示了预配置的问题管理系统以及它们用于创建从更改报告直接指向问题管理系统中问题的链接的模板。

系统问题链接模板
比特桶%URL%/问题/%ISSUE%
布吉拉%URL%/show_bug.cgi?id=%ISSUE%
GitHub%URL%/%ISSUE%
谷歌代码%URL%/detail?id=%ISSUE%
JIRA%URL%/%ISSUE%
螳螂%URL%/view.php?id=%ISSUE%
MKS 诚信%URL%/viewissue?selection=%ISSUE%
红米%URL%/issues/show/%ISSUE%
圣甲虫%URL%/issues/id/%ISSUE%
源锻造http://sourceforge.net/support/tracker.php?aid=%ISSUE%
追踪%URL%/ticket/%ISSUE%

如果您使用上述以外的问题管理系统,则需要为其配置问题链接模板。我们希望通过更多问题管理系统来扩展上表,因此如果您有上面未列出的工作配置,请通过为它创建问题来告诉我们。

注意:确保您的<issueManagement>/<url>正确。特别是,如果需要,请确保它有一个尾部斜杠。该插件无法为您添加此内容,因为它需要处理不同的问题管理系统。如果您的问题管理系统位于http://www.company.com/bugzilla/ ,如果您在pom.xml中输入http://www.company.com/bugzilla ,链接将不起作用。

如何生成 JIRA 报告

注意:要使用 JIRA 报告,必须配置项目pom.xml中的<issueManagement>部分。它可能看起来像这样:

<project>
  ...
  <issueManagement>
    <system>JIRA</system>
    <url>http://jira.codehaus.org/BrowseProject.jspa?id=10450</url>
  </issueManagement>
  ...
</project>

要生成 JIRA 报告,请将更改插件插入项目pom.xml的<reporting>部分

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <version>2.5</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>jira-report</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

并执行站点目标以生成报告。

mvn site

有关如何修改 JIRA 报告的信息,请参阅自定义 JIRA 报告示例。

如何通过电子邮件生成和发送公告

像往常一样,我们从配置项目的pom.xml开始。我们添加了发送电子邮件的基本配置,并指定了通知电子邮件的幸运收件人。

有关如何更改电子邮件发件人的信息,请参阅指定邮件发件人示例。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          ...
          <smtpHost>mail.yourhost.com</smtpHost>
          <smtpPort implementation="java.lang.Integer">25</smtpPort>
          <toAddresses>
            <toAddress implementation="java.lang.String">someones@email.com</toAddress>
            <toAddress implementation="java.lang.String">anothersomeone@email.com</toAddress>
          </toAddresses>
          ...
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

您现在可以通过执行以下命令来生成公告:

mvn changes:announcement-generate

如果要基于 JIRA 生成公告,则需要在pom.xml中进行配置,如下所示:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          ...
          <issueManagementSystems>
            <issueManagementSystem>JIRA</issueManagementSystem>
          </issueManagementSystems>
          ...
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

要基于changes.xml文件和 JIRA生成公告您应该像这样配置pom.xml

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-changes-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          ...
          <issueManagementSystems>
            <issueManagementSystem>changes.xml</issueManagementSystem>
            <issueManagementSystem>JIRA</issueManagementSystem>
          </issueManagementSystems>
          ...
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

这是您发送包含生成公告的电子邮件的方式:

mvn changes:announcement-mail