Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 89665 invoked from network); 22 Mar 2006 05:59:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2006 05:59:41 -0000 Received: (qmail 76254 invoked by uid 500); 22 Mar 2006 05:59:38 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 76192 invoked by uid 500); 22 Mar 2006 05:59:38 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 76110 invoked by uid 99); 22 Mar 2006 05:59:37 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Mar 2006 21:59:37 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 21 Mar 2006 21:59:33 -0800 Received: (qmail 89299 invoked by uid 65534); 22 Mar 2006 05:59:12 -0000 Message-ID: <20060322055912.89298.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r387742 [1/3] - in /maven/sandbox/plugins/changes-maven-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/announcement/ src/main/java/org/apa... Date: Wed, 22 Mar 2006 05:59:06 -0000 To: commits@maven.apache.org From: brett@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: brett Date: Tue Mar 21 21:59:01 2006 New Revision: 387742 URL: http://svn.apache.org/viewcvs?rev=387742&view=rev Log: Import of changes-maven-plugin code from https://svn.codehaus.org/mojo/trunk/mojo/changes-maven-plugin/, r1708 Code authored by people that have an Apache CLA on file: * Johnny Ruiz III (Initial contribution derived from code under https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk/changes, /jira and /announcement) * Allan Ramirez * Trygve Laugstol * Brian Fox * Brett Porter * Jason van Zyl * Carlos Sanchez Contains code donated under the Apache License 2.0 by: * Brent Worden - r1160, Document the 'desc' attribute of a release. * Kris Bravo - r1037, update the "How To" document * Kris Bravo / Julian Wood - r1042, update the "How To" document All code is under the Apache License v2.0 Added: maven/sandbox/plugins/changes-maven-plugin/ maven/sandbox/plugins/changes-maven-plugin/pom.xml (with props) maven/sandbox/plugins/changes-maven-plugin/src/ maven/sandbox/plugins/changes-maven-plugin/src/main/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMojo.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncement.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementDownloader.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementParser.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/mailsender/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/mailsender/ProjectJavamailMailSender.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesReportGenerator.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesXML.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Release.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/JiraDownloader2.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/JiraIssue.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/JiraMojo.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/JiraReportGenerator.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/jira/JiraXML.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/resource/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/resource/loader/ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/resource/loader/ProjectResourceLoader.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/resources/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/META-INF/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/META-INF/plexus/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/META-INF/plexus/components.xml (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/resources/changes-report.properties (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/resources/jira-report.properties (with props) maven/sandbox/plugins/changes-maven-plugin/src/main/resources/org/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/org/apache/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/org/apache/maven/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/org/apache/maven/announcement/ maven/sandbox/plugins/changes-maven-plugin/src/main/resources/org/apache/maven/announcement/announcement.vm maven/sandbox/plugins/changes-maven-plugin/src/site/ maven/sandbox/plugins/changes-maven-plugin/src/site/apt/ maven/sandbox/plugins/changes-maven-plugin/src/site/apt/howto.apt (with props) maven/sandbox/plugins/changes-maven-plugin/src/site/resources/ maven/sandbox/plugins/changes-maven-plugin/src/site/resources/changes-report.html (with props) maven/sandbox/plugins/changes-maven-plugin/src/site/resources/jira-report.html (with props) maven/sandbox/plugins/changes-maven-plugin/src/site/site.xml (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/announcement/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/changes/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/changes/ActionTest.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/changes/ReleaseTest.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/jira/ maven/sandbox/plugins/changes-maven-plugin/src/test/java/org/apache/maven/jira/JiraIssueTest.java (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/resources/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/META-INF/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/META-INF/plexus/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/META-INF/plexus/components.xml (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/resources/changes.xml (with props) maven/sandbox/plugins/changes-maven-plugin/src/test/resources/org/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/org/apache/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/org/apache/maven/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/org/apache/maven/announcement/ maven/sandbox/plugins/changes-maven-plugin/src/test/resources/org/apache/maven/announcement/announcement.vm Added: maven/sandbox/plugins/changes-maven-plugin/pom.xml URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/pom.xml?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/pom.xml (added) +++ maven/sandbox/plugins/changes-maven-plugin/pom.xml Tue Mar 21 21:59:01 2006 @@ -0,0 +1,83 @@ + + + mojo + org.codehaus.mojo + 6 + + 4.0.0 + changes-maven-plugin + maven-plugin + Maven Changes Report Plugin + 2.0-beta-2-SNAPSHOT + + + jruiz + Johnny Ruiz III + jruiz@apache.org + + + aramirez + Allan Ramirez + aramirez@exist.com + + + + + org.apache.maven + maven-settings + 2.0-beta-1 + + + plexus + plexus-velocity + 1.1.1 + + + plexus + plexus-mail-sender-simple + 1.0-alpha-2 + + + plexus + plexus-mail-sender-javamail + 1.0-alpha-2 + + + org.apache.maven.reporting + maven-reporting-api + 2.0-beta-1 + + + commons-logging + commons-logging + 1.0.3 + + + org.apache.maven.reporting + maven-reporting-impl + 2.0-beta-1 + + + velocity + velocity + 1.4 + + + doxia + doxia-sink-api + 1.0-alpha-4 + + + commons-httpclient + commons-httpclient + 2.0.2 + + + + + mojo.website + Mojo Website + scpexe://beaver.codehaus.org/home/projects/mojo/public_html/changes-maven-plugin + + + \ No newline at end of file Propchange: maven/sandbox/plugins/changes-maven-plugin/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/pom.xml ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java (added) +++ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java Tue Mar 21 21:59:01 2006 @@ -0,0 +1,352 @@ + +package org.apache.maven.announcement; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.maven.announcement.mailsender.ProjectJavamailMailSender; +import org.apache.maven.model.Developer; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.console.ConsoleLogger; +import org.codehaus.plexus.mailsender.MailSenderException; +import org.codehaus.plexus.util.IOUtil; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; + + + +/** + * Maven Announcement mailer goal. + * @goal announcement-mail + * @execute goal="announcement-generate" + * @description Goal which sends the template thru email + * @author aramirez@exist.com + */ + +public class AnnouncementMailMojo extends AbstractMojo +{ + //========================================= + // announcement-mail goal fields + //========================================= + + /** + * @parameter expression=${project} + * @readonly + */ + private MavenProject project; + + /** + * Smtp Server + * @parameter + * @required + */ + private String smtpHost; + + /** + * Port + * @parameter default-value="25"; + * @required + */ + private int smtpPort; + + /** + * @parameter + */ + private String username; + + /** + * @parameter + */ + private String password; + + /** + * @parameter default-value="false" + */ + private boolean sslMode; + + /** + * Subject for the email + * @parameter default-value="[ANNOUNCEMENT] - ${project.artifactId} ${project.version} release!" + * @required + */ + private String subject; + + /** + * Recipient email address. + * @parameter + * @required + */ + private List toAddresses; + + /** + * Sender + * @parameter expression="${project.developers}" + * @required + */ + private List from; + + /** + * Directory which contains the template for announcement email. + * @parameter expression="${project.build.directory}/announcement" + * @required + */ + private String templateOutputDirectory; + + /** + * @parameter default-value="announcement.vm" + * @required + */ + private String template; + + private ProjectJavamailMailSender mailer = new ProjectJavamailMailSender(); + + + public void execute() throws MojoExecutionException + { + template = templateOutputDirectory + "/" + template; + + ConsoleLogger logger = new ConsoleLogger( 0, "base" ); + + mailer.enableLogging( logger ); + + mailer.setSmtpHost( getSmtpHost() ); + + mailer.setSmtpPort( getSmtpPort() ); + + mailer.setSslMode( sslMode ); + + if( username != null ) + { + mailer.setUsername( username ); + } + + if( password != null ) + { + mailer.setPassword( password ); + } + mailer.initialize(); + + if( isTextFileExisting( template ) ) + { + getLog().info( "Connecting to Host: " + getSmtpHost() + ":" + getSmtpPort() ); + + sendMessage( ); + } + else + { + if( template != null ) + { + if( isTextFileExisting( template ) ) + { + getLog().info( "Connecting to Host: " + getSmtpHost() + " : " + getSmtpPort() ); + + sendMessage( ); + } + else + { + throw new MojoExecutionException( "Announcement template " + template + " not found..." ); + } + } + else + { + throw new MojoExecutionException( "Announcement template " + template + " not found..." ); + } + } + } + + /** + * Send the email + * + * @param recipient receiver of the email + * @throws MojoExecutionException + */ + protected void sendMessage() throws MojoExecutionException + { + String email = ""; + + try + { + int i=0; + + String[] from = getFirstDevInfo( getFrom() ); + + while( i < getToAddresses().size() ) + { + email = getToAddresses().get( i ).toString(); + + getLog().info( "Sending mail... " + email ); + + mailer.send( getSubject(), IOUtil.toString( readAnnouncement( template ) ), email, "", from[0], from[1] ); + + getLog().info("Sent..."); + + i++; + } + } + catch( IOException ioe ) + { + throw new MojoExecutionException( "Failed to send email.", ioe ); + } + catch( MailSenderException e ) + { + throw new MojoExecutionException( "Failed to send email < " + email + " >", e ); + } + } + + protected boolean isTextFileExisting( String fileName ) + { + boolean found = false; + + File f = new File( fileName ); + + if( f.exists() ) + { + found = true; + } + return found; + } + + /** + * Read the announcement generated file + * @param fileName Accepts filename to be read. + * @return fileReader Return the FileReader. + */ + public FileReader readAnnouncement( String fileName ) throws MojoExecutionException + { + FileReader fileReader = null; + + try + { + File file = new File( fileName ); + + fileReader = new FileReader( file ); + } + catch( FileNotFoundException fnfe ) + { + throw new MojoExecutionException( "File not found. " + fileName ); + } + return fileReader; + } + + /** + * Retrieve the 1st name and email address found in the developers list + * @param fromNames Accepts List of developers. + * @return fromAddress Returns the 1st email address found in the list. + */ + public String[] getFirstDevInfo( List fromNames ) throws MojoExecutionException + { + String fromAddress = ""; + + String fromName = ""; + + String[] info = new String[2]; + + if( fromNames.size() > 0 ) + { + Developer developer = ( Developer ) fromNames.get( 0 ); + + fromAddress = developer.getEmail(); + + fromName = developer.getName(); + + info[0] = fromAddress; + + info[1] = fromName; + + getLog().info( "email retrieved. " + fromAddress + " < " + fromName + " > " ); + + if( fromAddress == null || fromAddress.equals( "" ) ) + { + throw new MojoExecutionException( "Email address in section is required." ); + } + } + else + { + throw new MojoExecutionException( "Email address in section is required." ); + } + return info; + } + + //================================ + // announcement-mail accessors + //================================ + + public String getSmtpHost() + { + return smtpHost; + } + + public void setSmtpHost(String smtpHost) + { + this.smtpHost = smtpHost; + } + + public int getSmtpPort() + { + return smtpPort; + } + + public void setSmtpPort(int smtpPort) + { + this.smtpPort = smtpPort; + } + + public String getSubject() + { + return subject; + } + + public void setSubject(String subject) + { + this.subject = subject; + } + + public List getFrom() + { + return from; + } + + public void setFrom(List from) + { + this.from = from; + } + + public MavenProject getProject() + { + return project; + } + + public void setProject(MavenProject project) + { + this.project = project; + } + + public List getToAddresses() + { + return toAddresses; + } + + public void setToAddresses(List toAddresses) + { + this.toAddresses = toAddresses; + } +} Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMailMojo.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMojo.java URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMojo.java?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMojo.java (added) +++ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/AnnouncementMojo.java Tue Mar 21 21:59:01 2006 @@ -0,0 +1,583 @@ +package org.apache.maven.announcement; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.maven.changes.ChangesXML; +import org.apache.maven.changes.Release; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.context.Context; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.exception.VelocityException; +import org.codehaus.plexus.velocity.VelocityComponent; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.List; + +/** + * @goal announcement-generate + * @description Goal which generate the template for announcement + * @author aramirez@exist.com + * @version $Id$ + * + * @requiresDependencyResolution test + */ +public class AnnouncementMojo extends AbstractMojo +{ + /** + * Directory where the template file will be generated + * @parameter expression="${project.build.directory}/announcement" + * @required + */ + private String outputDirectory; + + /** + * @parameter expression="${project.groupId}" + * @readonly + */ + private String groupId; + + /** + * @parameter expression="${project.artifactId}" + * @readonly + */ + private String artifactId; + + /** + * Version of the plugin + * @parameter expression="${project.version}" + * @readonly + */ + private String version; + + /** + * Distribution url of the plugin + * @parameter expression="${project.url}" + * @required + */ + private String url; + + /** + * Packaging structure based on the pom + * @parameter expression="${project.packaging}" + * @readonly + */ + private String packaging; + + /** + * @parameter expression="${project.build.finalName}.${project.packaging}" + * @required + */ + private String finalName; + + /** + * URL where the plugin can be downloaded + * @parameter expression="${project.url}/${project.build.finalName}.jar" + */ + private String urlDownload; + + /** + * Directory which contains the changes.xml file + * @parameter expression="${basedir}/src/changes/changes.xml" + * @required + */ + private String xmlPath; + + /** + * Name of the team that develops the project + * @parameter default-value="${project.artifactId}-team" + * @required + */ + private String developmentTeam; + + /** + * Short description or introduction of the released project. + * @parameter expression="${project.description}" + */ + private String introduction; + + /** + * Velocity Component + * @parameter expression="${component.org.codehaus.plexus.velocity.VelocityComponent}" + * @readonly + */ + private VelocityComponent velocity; + + /** + * Name of the tempalte to be generated + * @parameter default-value="announcement.vm" + * @required + */ + private String template; + + /** + * Directory that contains the template + * @parameter default-value="org/apache/maven/announcement" + * @required + */ + private String templateDirectory; + + private ChangesXML xml; + + //=======================================// + // Jira-Announcement Needed Parameters // + //=======================================// + + /** + * The Maven Project. + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + /** + * Settings XML configuration. + * + * @parameter expression="${settings}" + * @required + * @readonly + */ + private Settings setting; + + /** + * Flag to determine that the plugin will generate a jira announcement + * @parameter expression="${generateJiraAnnouncement}" default-value="false" + * @required + */ + private boolean generateJiraAnnouncement; + + /** + * Only closed issues are needed. + * @parameter default-value="Closed" + */ + private String statusId; + + /** + * Only fixed issues are needed + * @parameter default-value="Fixed" + */ + private String resolutionId; + + /** + * Directory containing the XML file of jira-announcement to be parse + * @parameter expression="${project.build.directory}/jira-announcement.xml" + * @required + * @readonly + */ + private String jiraXML; + + /** + * @parameter default-value="25" + * @required + */ + private int nbEntries; + + //=======================================// + // announcement-generate execution // + //=======================================// + + /** + * Generate the template + * + * @throws MojoExecutionException + */ + public void execute() throws MojoExecutionException + { + if( !generateJiraAnnouncement ) + { + setXml( new ChangesXML( getXmlPath() ) ); + + doGenerate( getXml() ); + } + else + { + doJiraGenerate(); + } + } + + /** + * Add the parameters to velocity context + * + * @param xml parsed changes.xml + * @throws MojoExecutionException + */ + public void doGenerate(ChangesXML xml) throws MojoExecutionException + { + try + { + Context context = new VelocityContext(); + + List releaseList = xml.getReleaseList(); + + getLog().info( "Creating file..." ); + + if( getIntroduction() == null || getIntroduction().equals( "" ) ) + { + setIntroduction( getUrl() ); + } + + context.put( "releases" , releaseList ); + + context.put( "groupId" , getGroupId() ); + + context.put( "artifactId" , getArtifactId() ); + + context.put( "version" , getVersion() ); + + context.put( "packaging" , getPackaging() ); + + context.put( "url" , getUrl() ); + + context.put( "release" , getLatestRelease( releaseList ) ); + + context.put( "introduction" , getIntroduction() ); + + context.put( "developmentTeam" , getDevelopmentTeam() ); + + context.put( "finalName" , getFinalName() ); + + context.put( "urlDownload" , getUrlDownload() ); + + processTemplate( context, getOutputDirectory(), template ); + } + catch( ResourceNotFoundException rnfe ) + { + throw new MojoExecutionException( "resource not found." ); + } + catch( VelocityException ve ) + { + throw new MojoExecutionException( ve.toString() ); + } + catch( IOException ioe ) + { + throw new MojoExecutionException( ioe.toString() ); + } + } + + public void doGenerate( List releases ) throws MojoExecutionException + { + try + { + Context context = new VelocityContext(); + + getLog().info( "Creating file..." ); + + if( getIntroduction() == null || getIntroduction().equals( "" ) ) + { + setIntroduction( getUrl() ); + } + + context.put( "releases" , releases ); + + context.put( "groupId" , getGroupId() ); + + context.put( "artifactId" , getArtifactId() ); + + context.put( "version" , getVersion() ); + + context.put( "packaging" , getPackaging() ); + + context.put( "url" , getUrl() ); + + context.put( "release" , getLatestRelease( releases ) ); + + context.put( "introduction" , getIntroduction() ); + + context.put( "developmentTeam" , getDevelopmentTeam() ); + + context.put( "finalName" , getFinalName() ); + + context.put( "urlDownload" , getUrlDownload() ); + + processTemplate( context, getOutputDirectory(), template ); + } + catch( ResourceNotFoundException rnfe ) + { + throw new MojoExecutionException( "resource not found." ); + } + catch( VelocityException ve ) + { + throw new MojoExecutionException( ve.toString() ); + } + catch( IOException ioe ) + { + throw new MojoExecutionException( ioe.toString() ); + } + } + + /** + * Get the latest release by matching the release in + * changes.xml and in the version of the pom + * + * @param releases list of releases in changes.xml + * @throws MojoExecutionException + */ + public Release getLatestRelease( List releases ) throws MojoExecutionException + { + boolean isFound = false; + + Release release = null; + + for( int i=0; i 0 ) ) + { + if ( this.filter.charAt( 0 ) == '&' ) + { + return this.filter.substring( 1 ); + } + + return this.filter; + } + + StringBuffer localFilter = new StringBuffer(); + + // get the Status Ids + if ( statusIds != null ) + { + String[] stats = statusIds.split( "," ); + + for ( int i = 0; i < stats.length; i++ ) + { + String statusParam = (String) statusMap.get( stats[i] ); + + if ( statusParam != null ) + { + localFilter.append( "&statusIds=" + statusParam ); + } + } + } + + + // get the Priority Ids + if ( priorityIds != null ) + { + String[] prios = priorityIds.split( "," ); + + for ( int i = 0; i < prios.length; i++ ) + { + String priorityParam = (String) priorityMap.get( prios[i] ); + + if ( priorityParam != null ) + { + localFilter.append( "&priorityIds=" + priorityParam ); + } + } + } + + if ( resolutionIds != null ) + { + // get the Resolution Ids + String[] resos = resolutionIds.split( "," ); + + for ( int i = 0; i < resos.length; i++ ) + { + String resoParam = (String) resolutionMap.get( resos[i] ); + + if ( resoParam != null ) + { + localFilter.append( "&resolutionIds=" + resoParam ); + } + } + } + + // add all components + if ( component != null ) + { + String[] components = component.split( "," ); + + for ( int i = 0; i < components.length; i++ ) + { + if ( components[i].length() > 0 ) + { + localFilter.append( "&component=" + components[i] ); + } + } + } + + // add default sorting (by priority and then creation date) + String sort = "&sorter/field=created&sorter/order=DESC" + "&sorter/field=priority&sorter/order=DESC"; + + return localFilter + sort; + } + + /** + * Execute the query on the JIRA server. + * + * @throws Exception on error + */ + public void doExecute() + throws Exception + { + try + { + HttpClient cl = new HttpClient(); + + HttpState state = new HttpState(); + + HostConfiguration hc = new HostConfiguration(); + + cl.setHostConfiguration( hc ); + + cl.setState( state ); + + determineProxy( cl ); + + Map urlMap = getJiraUrlAndIssueId(); + + String jiraUrl = (String) urlMap.get("url"); + + String jiraId = (String) urlMap.get("id"); + + doAuthentication( cl, jiraUrl ); + + // create the URL for getting the proper issues from JIRA + String fullURL = jiraUrl + "/secure/IssueNavigator.jspa?view=rss&pid=" + jiraId; + + //TODO:only for a temporary use case, + //hardcoded of for fix version + fullURL += "&fixfor=12000"; + + fullURL += createFilter(); + + fullURL += ( "&tempMax=" + nbEntriesMax + "&reset=true&decorator=none" ); + + // execute the GET + download( cl, fullURL ); + } + catch ( Exception e ) + { + getLog().error( "Error accessing " + project.getIssueManagement().getUrl(), e ); + } + } + + private Map getJiraUrlAndIssueId() + { + HashMap urlMap = new HashMap(); + + String url = project.getIssueManagement().getUrl(); + + // chop off the parameter part + int pos = url.indexOf( "?" ); + + // and get the id while we're at it + String id = ""; + + if ( pos >= 0 ) + { + // url + id = url.substring( url.lastIndexOf( "=" ) + 1 ); + } + + String jiraUrl = url.substring( 0, url.lastIndexOf( "/" ) ); + + if ( jiraUrl.endsWith( "secure" ) ) + { + jiraUrl = jiraUrl.substring( 0, jiraUrl.lastIndexOf( "/" ) ); + } + getLog().info( "Jira lives at: " + jiraUrl ); + + urlMap.put("url", jiraUrl); + + urlMap.put("id", id); + + return urlMap; + } + + /** + * Authenticate against webserver and into JIRA if we have to. + * + * @param client the HttpClient + * @param jiraUrl the JIRA installation + */ + private void doAuthentication( HttpClient client, final String jiraUrl ) + { + // check and prepare for basic authentication + if ( ( webUser != null ) && ( webUser.length() > 0 ) ) + { + client.getState().setAuthenticationPreemptive( true ); + + Credentials defaultcreds = new UsernamePasswordCredentials( webUser, webPassword ); + + getLog().info( "Using username: " + webUser + " for Basic Authentication against the webserver at " + jiraUrl ); + + client.getState().setCredentials( null, null, defaultcreds ); + } + + // log into JIRA if we have to + String loginUrl = null; + + if ( ( jiraUser != null ) && ( jiraUser.length() > 0 ) && ( jiraPassword != null ) ) + { + StringBuffer loginLink = new StringBuffer( jiraUrl ); + + loginLink.append( "/login.jsp?os_destination=/secure/" ); + + loginLink.append( "&os_username=" ).append( jiraUser ); + + getLog().info( "Login URL: " + loginLink + "&os_password=*******" ); + + loginLink.append( "&os_password=" ).append( jiraPassword ); + + loginUrl = loginLink.toString(); + } + + // execute the login + if ( loginUrl != null ) + { + GetMethod loginGet = new GetMethod( loginUrl ); + + try + { + client.executeMethod( loginGet ); + + getLog().info( "Succesfully logged in into JIRA." ); + } + catch ( Exception e ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().error( "Error trying to login into JIRA:", e ); + } + else + { + getLog().error( "Error trying to login into JIRA. Cause is: " + e.getLocalizedMessage() ); + } + // continue any way, probably will fail later if authentication was necesaaray afterall + } + } + } + + /** + * Setup proxy access if we have to. + * + * @param client the HttpClient + */ + private void determineProxy( HttpClient client ) + { + // see whether there is any proxy defined in maven + Proxy proxy = null; + + String proxyHost = null; + + int proxyPort = 0; + + String proxyUser = null; + + String proxyPass = null; + + if ( project == null ) + { + getLog().error( "No project set. No proxy info available." ); + + return; + } + + if ( settings != null ) + { + proxy = settings.getActiveProxy(); + } + + if ( proxy != null ) + { + proxyHost = settings.getActiveProxy().getHost(); + + proxyPort = settings.getActiveProxy().getPort(); + + proxyUser = settings.getActiveProxy().getUsername(); + + proxyPass = settings.getActiveProxy().getPassword(); + + getLog().info(proxyPass); + } + + if ( proxyHost != null ) + { + client.getHostConfiguration().setProxy( proxyHost, proxyPort ); + + getLog().info( "Using proxy: " + proxyHost + " at port " + proxyPort ); + + if ( proxyUser != null ) + { + getLog().info( "Using proxy user: " + proxyUser ); + + client.getState().setProxyCredentials( null, null, + new UsernamePasswordCredentials( proxyUser, proxyPass ) ); + } + } + } + + /** + * Downloads the given link using the configured HttpClient, possibly following redirects. + * + * @param cl the HttpClient + * @param link the JiraUrl + * @return + */ + private void download( final HttpClient cl, final String link ) + { + try + { + GetMethod gm = new GetMethod( link ); + + getLog().info( "Downloading " + link ); + + gm.setFollowRedirects( true ); + + cl.executeMethod( gm ); + + final String strGetResponseBody = gm.getResponseBodyAsString(); + + // write the reponse to file + PrintWriter pw = new PrintWriter( new FileWriter( getOutput() ) ); + + pw.print( strGetResponseBody ); + + pw.close(); + + StatusLine sl = gm.getStatusLine(); + + if ( sl == null ) + { + getLog().info( "Unknown error validating link : " + link ); + + return; + } + + // if we get a redirect, do so + if ( gm.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY ) + { + Header locationHeader = gm.getResponseHeader( "Location" ); + + if ( locationHeader == null ) + { + getLog().info( "Site sent redirect, but did not set Location header" ); + } + else + { + String newLink = locationHeader.getValue(); + + getLog().debug( "Following redirect to " + newLink ); + + download( cl, newLink ); + } + } + + if ( gm.getStatusCode() != HttpStatus.SC_OK ) + { + getLog().warn( "Received: [" + gm.getStatusCode() + "]" ); + } + } + catch ( HttpException e ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().error( "Error downloading issues from JIRA:", e ); + } + else + { + getLog().error( "Error downloading issues from JIRA url : " + e.getLocalizedMessage() ); + + } + } + catch ( IOException e ) + { + if ( getLog().isDebugEnabled() ) + { + getLog().error( "Error downloading issues from JIRA :", e ); + } + else + { + getLog().error( "Error downloading issues from JIRA. Cause is " + e.getLocalizedMessage() ); + } + } + } + + /** + * Set the output file for the log. + * + * @param thisOutput the output file + */ + public void setOutput( File thisOutput ) + { + this.output = thisOutput; + } + + public File getOutput() + { + return this.output; + } + + /** + * Sets the project. + * + * @param thisProject The project to set + */ + public void setMavenProject( Object thisProject ) + { + this.project = (MavenProject) thisProject; + } + + /** + * Sets the maximum number of Issues to show. + * + * @param nbEntries The maximum number of Issues + */ + public void setNbEntries( final int nbEntries ) + { + nbEntriesMax = nbEntries; + } + + /** + * Sets the statusIds. + * + * @param thisStatusIds The id(s) of the status to show, as comma separated string + */ + public void setStatusIds( String thisStatusIds ) + { + statusIds = thisStatusIds; + } + + /** + * Sets the priorityIds. + * + * @param thisPriorityIds The id(s) of the priority to show, as comma separated string + */ + public void setPriorityIds( String thisPriorityIds ) + { + priorityIds = thisPriorityIds; + } + + /** + * Sets the resolutionIds. + * + * @param thisResolutionIds The id(s) of the resolution to show, as comma separated string + */ + public void setResolutionIds( String thisResolutionIds ) + { + resolutionIds = thisResolutionIds; + } + + /** + * Sets the password for authentication against the webserver. + * + * @param thisWebPassword The password of the webserver + */ + public void setWebPassword( String thisWebPassword ) + { + this.webPassword = thisWebPassword; + } + + /** + * Sets the username for authentication against the webserver. + * + * @param thisWebUser The username of the webserver + */ + public void setWebUser( String thisWebUser ) + { + this.webUser = thisWebUser; + } + + /** + * Sets the password to log into a secured JIRA. + * + * @param thisJiraPassword The password for JIRA + */ + public void setJiraPassword( final String thisJiraPassword ) + { + this.jiraPassword = thisJiraPassword; + } + + /** + * Sets the username to log into a secured JIRA. + * + * @param thisJiraUser The username for JIRA + */ + public void setJiraUser( String thisJiraUser ) + { + this.jiraUser = thisJiraUser; + } + + /** + * Sets the filter to apply to query to JIRA. + * + * @param thisFilter The filter to query JIRA + */ + public void setFilter( String thisFilter ) + { + this.filter = thisFilter; + } + + /** + * Sets the component(s) to apply to query JIRA. + * + * @param theseComponents The id(s) of components to show, as comma separated string + */ + public void setComponent( String theseComponents ) + { + this.component = theseComponents; + } + + public void setLog( Log log ) + { + this.log = log; + } + + private org.apache.maven.plugin.logging.Log getLog() + { + return log; + } + + public void setSettings(Settings settings) + { + this.settings = settings; + } +} Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementDownloader.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementDownloader.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementParser.java URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementParser.java?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementParser.java (added) +++ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/JiraAnnouncementParser.java Tue Mar 21 21:59:01 2006 @@ -0,0 +1,197 @@ +package org.apache.maven.announcement; + +import org.apache.maven.changes.Action; +import org.apache.maven.changes.Release; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * XML Parser for Jira Announcement + * + * @author aramirez@exist.com + */ +public class JiraAnnouncementParser + extends DefaultHandler +{ + private String elementValue; + + private String parentElement = ""; + + private JiraAnnouncement issue; + + List issues = new ArrayList(); + + public JiraAnnouncementParser( String xmlPath ) + { + File xml = new File( xmlPath ); + + parseJira( xml ); + } + + public JiraAnnouncementParser( File xmlPath ) + { + parseJira( xmlPath ); + } + + public void parseJira( File xml ) + { + SAXParserFactory factory = SAXParserFactory.newInstance(); + + try + { + SAXParser parser = factory.newSAXParser(); + + parser.parse( xml, this ); + } + catch( Throwable t ) + { + t.printStackTrace(); + } + } + + public void startElement( String namespaceURI, String sName, String qName, Attributes attrs ) + throws SAXException + { + if( qName.equals( "item" ) ) + { + issue = new JiraAnnouncement(); + + parentElement = "item"; + } + } + + public void endElement( String namespaceURI, String sName, String qName ) + throws SAXException + { + if( qName.equals( "item" ) ) + { + issues.add( issue ); + + parentElement = ""; + } + else if( qName.equals( "title" ) && parentElement.equals( "item" ) ) + { + issue.setTitle( elementValue ); + } + else if( qName.equals( "key" ) ) + { + issue.setKey( elementValue ); + } + else if( qName.equals( "link" ) && parentElement.equals( "item" ) ) + { + issue.setLink( elementValue ); + } + else if( qName.equals( "summary" ) ) + { + issue.setSummary( elementValue ); + } + else if( qName.equals( "type" ) ) + { + issue.setType( elementValue ); + } + else if( qName.equals( "status" ) ) + { + issue.setStatus( elementValue ); + } + else if( qName.equals( "resolution" ) ) + { + issue.setResolution( elementValue ); + } + else if( qName.equals( "assignee" ) ) + { + issue.setAssignee( elementValue ); + } + else if( qName.equals( "reporter" ) ) + { + issue.setReporter( elementValue ); + } + else if( qName.equals( "fixVersion" ) ) + { + issue.setFixVersion( elementValue ); + } + else if( qName.equals( "comment" ) ) + { + issue.addComment( elementValue ); + } + } + + public void characters( char[] buff, int offset, int len ) + throws SAXException + { + String str = new String( buff, offset, len ); + + String string = str.trim(); + + if( !string.equals( "" ) ) + { + elementValue = string; + } + } + + public List getIssues() + { + return this.issues; + } + + public List getReleases( List issues ) + { + List releases = new ArrayList(); + + Release release = new Release(); + + String type = ""; + + for( int i=0; i 0 ) + { + InternetAddress[] addressTo = new InternetAddress[mail.getToAddresses().size()]; + int count = 0; + for ( Iterator i = mail.getToAddresses().iterator(); i.hasNext(); ) + { + String address = ((MailMessage.Address) i.next()).getRfc2822Address(); + addressTo[count++] = new InternetAddress( address ); + } + msg.setRecipients( Message.RecipientType.TO, addressTo ); + } + + if ( mail.getCcAddresses().size() > 0 ) + { + InternetAddress[] addressCc = new InternetAddress[mail.getCcAddresses().size()]; + int count = 0; + for ( Iterator i = mail.getCcAddresses().iterator(); i.hasNext(); ) + { + String address = ((MailMessage.Address) i.next()).getRfc2822Address(); + addressCc[count++] = new InternetAddress( address ); + } + msg.setRecipients( Message.RecipientType.CC, addressCc ); + } + + if ( mail.getBccAddresses().size() > 0 ) + { + InternetAddress[] addressBcc = new InternetAddress[mail.getBccAddresses().size()]; + int count = 0; + for ( Iterator i = mail.getBccAddresses().iterator(); i.hasNext(); ) + { + String address = ((MailMessage.Address) i.next()).getRfc2822Address(); + addressBcc[count++] = new InternetAddress( address ); + } + msg.setRecipients( Message.RecipientType.BCC, addressBcc ); + } + + // Setting the Subject and Content Type + msg.setSubject( mail.getSubject() ); + msg.setContent( mail.getContent(), "text/plain" ); + + if ( mail.getSendDate() != null ) + { + msg.setHeader( "Date", DateFormatUtils.getDateHeader( mail.getSendDate() ) ); + } + else + { + msg.setHeader( "Date", DateFormatUtils.getDateHeader( new Date() ) ); + } + + // Send the message + Transport.send( msg ); + } + catch ( MessagingException e ) + { + throw new MailSenderException( "Error while sending mail.", e ); + } + } +} Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/mailsender/ProjectJavamailMailSender.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/announcement/mailsender/ProjectJavamailMailSender.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java (added) +++ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java Tue Mar 21 21:59:01 2006 @@ -0,0 +1,95 @@ +package org.apache.maven.changes; + +/* + * Copyright 2001-2005 The Codehaus. + * + * Licensed 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. + */ +public class Action +{ + private String action; + + private String dev; + + private String dueTo; + + private String dueToEmail; + + private String issue; + + private String type; + + public Action() + { + } + + public void setAction( String action ) + { + this.action = action; + } + + public String getAction() + { + return action; + } + + public void setDev( String dev ) + { + this.dev = dev; + } + + public String getDev() + { + return dev; + } + + public void setDueTo( String dueTo ) + { + this.dueTo = dueTo; + } + + public String getDueTo() + { + return dueTo; + } + + public void setDueToEmail( String dueToEmail ) + { + this.dueToEmail = dueToEmail; + } + + public String getDueToEmail() + { + return dueToEmail; + } + + public void setIssue( String issue ) + { + this.issue = issue; + } + + public String getIssue() + { + return issue; + } + + public void setType( String type ) + { + this.type = type; + } + + public String getType() + { + return type; + } +} Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/Action.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java URL: http://svn.apache.org/viewcvs/maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java?rev=387742&view=auto ============================================================================== --- maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java (added) +++ maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java Tue Mar 21 21:59:01 2006 @@ -0,0 +1,149 @@ +package org.apache.maven.changes; + +/* + * Copyright 2001-2005 The Codehaus. + * + * Licensed 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. + */ + +import java.io.File; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.apache.maven.project.MavenProject; +import org.apache.maven.reporting.AbstractMavenReport; +import org.apache.maven.reporting.MavenReportException; +import org.codehaus.doxia.site.renderer.SiteRenderer; + +/** + * @goal changes-report + * @description Goal wich creates a nicely formatted Changes Report in html format from changes.xml. + * @author Johnny R. Ruiz III + * @version $Id$ + */ +public class ChangesMojo + extends AbstractMavenReport +{ + /** + * Directory where reports will go. + * @parameter expression="${project.build.directory}/site " + * @required + * @readonly + */ + private String outputDirectory; + + /** + * @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}" + * @required + * @readonly + */ + private SiteRenderer siteRenderer; + + /** + * @parameter expression="${project}" + * @required + * @readonly + */ + private MavenProject project; + + /** + * The changes.xml that will be converted into an html report. + * @parameter expression="${basedir}/src/changes/changes.xml" + * @required + */ + private String xmlPath; + + /** + * Template string that is used to discover the URL to use to display a bug report. + * There are 2 template tokens you can use. %URL%: this is computed by getting the + * <issueManagement><url> value from the POM, and removing the context path. %ISSUE% : + * this is the issue number. + * @parameter expression="%URL%/ViewIssue.jspa?key=%ISSUE%" + * + */ + private String link_template; + + /** + * @parameter expression="${project.issueManagement.url}" + * @readonly + */ + private String url; + + public void executeReport( Locale locale ) + throws MavenReportException + { + + File xmlFile = new File( xmlPath ); + + if ( !xmlFile.exists() ) + { + getLog().error( getBundle( locale ).getString( "report.changes.error" ) ); + + ChangesReportGenerator report = new ChangesReportGenerator(); + + report.doGenerateEmptyReport( getBundle( locale ), getSink(), getBundle( locale ) + .getString( "report.changes.error" ) ); + } + else + { + ChangesReportGenerator report = new ChangesReportGenerator( xmlPath ); + + if ( ( url == null ) || ( url.trim().equals( "" ) ) ) + { + getLog().warn( getBundle( locale ).getString( "report.changes.warn.url" ) ); + } + + report.setIssueLink( link_template ); + + report.setUrl( url ); + + report.doGenerateReport( getBundle( locale ), getSink() ); + } + + } + + public String getName( Locale locale ) + { + return getBundle( locale ).getString( "report.changes.name" ); + } + + public String getDescription( Locale locale ) + { + return getBundle( locale ).getString( "report.changes.description" ); + } + + protected SiteRenderer getSiteRenderer() + { + return siteRenderer; + } + + protected MavenProject getProject() + { + return project; + } + + public String getOutputName() + { + return "changes-report"; + } + + protected String getOutputDirectory() + { + return outputDirectory; + } + + private ResourceBundle getBundle( Locale locale ) + { + return ResourceBundle.getBundle( "changes-report", locale, this.getClass().getClassLoader() ); + } +} Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/sandbox/plugins/changes-maven-plugin/src/main/java/org/apache/maven/changes/ChangesMojo.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"