Author: bimargulies
Date: Mon Jun 27 13:15:01 2011
New Revision: 1140150
URL: http://svn.apache.org/viewvc?rev=1140150&view=rev
Log:
[MCHANGES-261]: Allow -Dchange.sender for the from address.
Added:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt
(with props)
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
(with props)
Modified:
maven/plugins/trunk/maven-changes-plugin/pom.xml
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
Modified: maven/plugins/trunk/maven-changes-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/pom.xml?rev=1140150&r1=1140149&r2=1140150&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-changes-plugin/pom.xml Mon Jun 27 13:15:01 2011
@@ -153,6 +153,22 @@ under the License.
</exclusion>
</exclusions>
</dependency>
+ <!-- javamail to parse an email address -->
+ <dependency>
+ <groupId>org.apache.geronimo.javamail</groupId>
+ <artifactId>geronimo-javamail_1.4_provider</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-javamail_1.4_spec</artifactId>
+ <version>1.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.javamail</groupId>
+ <artifactId>geronimo-javamail_1.4_mail</artifactId>
+ <version>1.7</version>
+ </dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-mail-sender-javamail</artifactId>
Added: maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt?rev=1140150&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt
(added)
+++ maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt Mon
Jun 27 13:15:01 2011
@@ -0,0 +1,3 @@
+This is a trivial project used to do manual tests of the announcement email
sending process.
+
+It is not run automatically; it would be too hard to catch and verify email.
Propchange:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/readme.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml?rev=1140150&view=auto
==============================================================================
---
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
(added)
+++
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
Mon Jun 27 13:15:01 2011
@@ -0,0 +1,65 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<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 report Project</title>
+ <author email="[email protected]">Mr Zloug</author>
+ </properties>
+ <body>
+ <release version="1.1" date="2005-03-01" description="Subsequent release">
+ <action dev="me" type="add">
+ Added additional documentation on how to configure the plugin.
+ </action>
+ <action dev="me" type="fix" issue="MCHANGES-88">
+ Enable retrieving component-specific issues.
+ </action>
+ <action dev="jruiz" type="remove" issue="MCHANGES-899">
+ The element type " link " must be terminated by the matching end-tag.
+ Deleted the erroneous code.
+ <fixes issue="MCHANGES-1"/>
+ <fixes issue="JIRA-12"/>
+ <dueto name="John Doe" email="[email protected]"/>
+ <dueto name="Jane Doe"/>
+ </action>
+ <action dev="you" type="update" issue="MCHANGES-999" system="bugzilla">
+ Handle different issue systems.
+ <fixes issue="bug-12345"/>
+ <dueto name="John Doe" email="[email protected]"/>
+ </action>
+ <action dev="him" type="update">
+ Updated dependencies.
+ <dueto name="John Doe" email="[email protected]"/>
+ <dueto name="Jane Doe"/>
+ </action>
+ </release>
+
+ <release version="1.0" date="2005-01-01" description="First release">
+ <action dev="me" type="update" issue="MCHANGES-47" due-to="others"
due-to-email="[email protected]">
+ Uploaded documentation on how to use the plugin.
+ <fixes issue="MCHANGES-88"/>
+ <fixes issue="JIRA-YYY"/>
+ <dueto name="John Doe" email="[email protected]"/>
+ <dueto name="Jane Doe"/>
+ </action>
+ </release>
+ </body>
+</document>
\ No newline at end of file
Propchange:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/plugins/trunk/maven-changes-plugin/src/it/email-sender/src/changes/changes.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java?rev=1140150&r1=1140149&r2=1140150&view=diff
==============================================================================
---
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
(original)
+++
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMailMojo.java
Mon Jun 27 13:15:01 2011
@@ -26,6 +26,9 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.List;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+
import org.apache.maven.model.Developer;
import org.apache.maven.plugin.MojoExecutionException;
import
org.apache.maven.plugin.announcement.mailsender.ProjectJavamailMailSender;
@@ -81,12 +84,27 @@ public class AnnouncementMailMojo
private String mailContentType;
/**
- * Defines the sender of the announcement if the list of developer is
empty or
- * if the sender is not a member of the development team.
+ * Defines the sender of the announcement email. This takes precedence
over the list
+ * of developers specified in the POM.
+ * if the sender is not a member of the development team. Note that since
this is a bean type,
+ * you cannot specify it from command level with <pre>-D</pre>. Use
+ * <pre>-Dchanges.sender='Your Name <you@domain>'</pre> instead.
*
* @parameter expression="${changes.mailSender}"
*/
private MailSender mailSender;
+
+ /**
+ * Defines the sender of the announcement. This takes precedence over both
${changes.mailSender}
+ * and the list of developers in the POM.
+ *
+ * This parameter parses an email address in standard RFC822 format, e.g.
+ * <pre>-Dchanges.sender='Your Name <you@domain>'</pre>.
+ *
+ * @parameter expression="${changes.sender}"
+ * @since 2.7
+ */
+ private String senderString;
/**
* The password used to send the email.
@@ -345,6 +363,18 @@ public class AnnouncementMailMojo
protected MailSender getActualMailSender()
throws MojoExecutionException
{
+ if (senderString != null)
+ {
+ try
+ {
+ InternetAddress ia = new InternetAddress(senderString, true);
+ return new MailSender(ia.getPersonal(), ia.getAddress());
+ }
+ catch ( AddressException e )
+ {
+ throw new MojoExecutionException("Invalid value for
change.sender: ", e);
+ }
+ }
if ( mailSender != null && mailSender.getEmail() != null )
{
return mailSender;