该插件用于创建变更报告、JIRA 报告和公告文本文件。它还可以通过电子邮件发送通知。
为了使用这个目标,只需在src/changes/ 目录中创建一个changes.xml 文件。这是一个典型的changes.xml示例 ,显示了语法:
<document>
<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>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
...
</project>
并执行站点目标以生成报告。
mvn site
如果您在changes.xml 文件中使用问题 属性并在pom.xml中配置了<issueManagement> 元素 ,则报告将包含指向问题管理系统中问题的链接。默认配置会生成指向 JIRA 的链接,但可以配置 .
注意: 如果您有其他问题跟踪器,请确保您的<issueManagement>/<url> 是正确的。特别是,如果需要,请确保它有一个尾部斜杠。该插件无法为您添加此内容,因为它需要处理不同的问题管理系统。如果您的问题管理系统位于http://www.company.com/bugzilla/ ,如果您 在pom.xml中输入http://www.company.com/bugzilla , 链接将不起作用 。
注意: 要使用 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>
<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>
<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中配置它, 或者在命令行中添加适当的参数,如下所示:
mvn changes:announcement-generate -DgenerateJiraAnnouncement=true
这是您发送包含生成公告的电子邮件的方式:
mvn changes:announcement-mail