The following is how to do that
1. Add the following plugin to pom.xml
1.1 Setup from and to emails
<properties> <releaseEmail.from.name>Release Mailler</releaseEmail.from.name> <releaseEmail.from.email>app-release@company.com</releaseEmail.from.email> <releaseEmail.to.email1>dev-team@company.com</releaseEmail.to.email1> <releaseEmail.to.email2>qa-team@company.com </releaseEmail.to.email2></properties>
1.2 Add the plugin
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changes-plugin</artifactId> <executions> <execution> <phase>deploy</phase> <goals> <goal>announcement-generate</goal> </goals> <id>announcement-generate</id> </execution> <execution> <phase>deploy</phase> <goals> <goal>announcement-mail</goal> </goals> <id>announcement-mail</id> </execution> </executions> <configuration> <smtpHost>mailone.real.com</smtpHost> <smtpPort implementation="java.lang.Integer">25</smtpPort> <mailSender> <name>${releaseEmail.from.name}</name> <email>${releaseEmail.from.email}</email> </mailSender> <toAddresses> <toAddress implementation="java.lang.String">${releaseEmail.to.email1}</toAddress> <toAddress implementation="java.lang.String">${releaseEmail.to.email2}</toAddress> </toAddresses> <developmentTeam>MyCompany.com Team</developmentTeam> <urlDownload>http://mavenrepo.company.com/repository/com/copmany/${project.artifactId}/${project.version}/</urlDownload> <introduction> This is a notification email that the ${project.version} build of ${project.name} has been code reviewed and deployed to Repository. Change list can be viewed on ${project.url}/changes-report.html</introduction> </configuration> </plugin>
2. Create a changes.xml in /src/changes/changes.xml
<?xml version="1.0" encoding="UTF-8"?> <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>Change Log for My App</title> </properties> <body> <release version="1.0.1" description="1st release" date="11/11/08"> <action dev="gdawoud" issue="12344" type="fix">Add a fix for bug</action> </release> <release version="1.0" description="1st release" date="11/11/08"> <action dev="gdawoud" issue="12344" type="fix">Add a fix for bug</action> </release> </body> </document>
And that is it.
Note: The changes plugin has an issue where if the changes.xml does not include an entry for a release matching the build release version, the build will fail after deploying the war/jar/etc to the maven repository. To Fix that you will have to check in an updated changes.xml with a matching release and retag it with the release tag then call cvs update and mvn release:prepare again
Check out the follow up blog
Check out the follow up blog
Hi George,
ReplyDeleteI also use changes plugin but try to configure it and run with
mvn changes:announcement-mail
only for root module of multi-module project. Unfortunately after mail was successfully sent for root module, Maven tries to do the same for sub-modules and (I think it does it correctly) fails with
"Announcement template D:\dibs\release\test\test-core\target\announcement\announcement.vm not found"
error.
Is there any way to avoid running announcement-mail goal for submodules? I'm in process of searching...
Thanks!
Alex
Hi Alex,
ReplyDeletei also use a multi-module project but i never build it from the root, i tend to want to build each subject when it is needed... so i have no tried that...
the best way i found ways to solve or a bug fix is to go into each plugin's bug tracking system and there is always an answer... not sure why they are listed on google.
Thanks George,
ReplyDeleteIt seems that for my situation there is no simple solution - I can not bind send mail goal to any valid lifecycle since release plugin does not have any, also pom does not support something like <nonRecursive> element for concrete plugin. So the only way is to provide - option directly in the command line:
mvn changes:announcement-mail -N
Hope one day we will have another way:)
Declaration and execution of annoucement-generate goal is useless because redundant :
ReplyDeleteannouncement-mail executes automatically
announcement-generate first.
plugin goal documentation :
Before this mojo executes, it will call:Single mojo: 'announcement-generate'