org.nuiton.helper.plugin
Class SendEmailMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.nuiton.plugin.AbstractPlugin
          extended by org.nuiton.helper.plugin.SendEmailMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, Plugin

public class SendEmailMojo
extends AbstractPlugin

Send a email.

Since:
1.0.3
Author:
tchemit
Is defined by the goal name:
send-email
Requires to be online to run:
true
Requires a Maven project to run:
true

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin
Plugin.InitState, Plugin.Packaging
 
Field Summary
protected  boolean dryRun
          A flag to test plugin but send nothing to redmine.
protected  File emailContentFile
          The Velocity template used to format the email announcement.
protected  String emailTitle
          The title of the email to send.
protected  String encoding
          The encoding used to read and write files.
protected  List<org.apache.maven.model.Developer> from
          Possible senders.
protected  String fromDeveloperId
          The id of the developer sending the announcement mail.
protected  String mailContentType
          Mail content type to use.
protected  MailSender mailSender
          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.
protected  String password
          The password used to send the email.
protected  org.apache.maven.project.MavenProject project
          Dependance du projet.
protected  boolean runOnce
          A flag to restirct only one run in a build (for multi-module context).
protected  boolean skipSendEmail
          A flag to skip the goal.
protected  String smtpHost
          Smtp Server.
protected  int smtpPort
          Port.
protected  boolean sslMode
          If the email should be sent in SSL mode.
protected  List<String> toAddresses
          Recipient email address.
protected  String username
          The username used to send the email.
protected  boolean verbose
          Un flag pour activer le mode verbeux.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
SendEmailMojo()
           
 
Method Summary
protected  boolean checkSkip()
          Checks if the mojo execution should be skipped.
protected  ProjectJavamailMailSender createMailer()
           
protected  org.codehaus.plexus.mailsender.MailMessage createMessage(String newsContent, MailSender mailSender)
           
protected  void doAction()
          Do plugin action.
 org.apache.maven.project.MavenProject getProject()
           
protected  void init()
          Method to initialize the mojo before doing any concrete actions.
protected  boolean isExecutionRoot()
           
protected  boolean isGoalSkip()
           
 boolean isVerbose()
           
 void setFrom(List<org.apache.maven.model.Developer> from)
           
 void setMailSender(MailSender mailSender)
           
 void setProject(org.apache.maven.project.MavenProject project)
           
 void setToAddresses(List<String> toAddresses)
           
 void setVerbose(boolean verbose)
           
 
Methods inherited from class org.nuiton.plugin.AbstractPlugin
acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, backupFile, checkPackaging, checkResource, checkRunOnceDone, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, execute, getBackupFile, getFileFromBasedir, getFilesToTreate, getFilesToTreateForRoots, getTemplate, initClassLoader, isFileNewerThanPomFile, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.plugin.Mojo
getLog, setLog
 

Field Detail

project

protected org.apache.maven.project.MavenProject project
Dependance du projet.

Since:
1.0.3
Is defined by:
default-value:
${project}
Is readonly.
Is required.

verbose

protected boolean verbose
Un flag pour activer le mode verbeux.

Since:
1.0.3
Is defined by:
expression:
${helper.verbose}
default-value:
${maven.verbose}

emailContentFile

protected File emailContentFile
The Velocity template used to format the email announcement.

Since:
1.0.3
Is defined by:
expression:
${helper.emailContentFile}
Is required.

emailTitle

protected String emailTitle
The title of the email to send.

Since:
1.0.3
Is defined by:
expression:
${helper.emailTitle}
Is required.

smtpHost

protected String smtpHost
Smtp Server.

Since:
1.0.3
Is defined by:
expression:
${helper.smtpHost}
Is required.

smtpPort

protected int smtpPort
Port.

Since:
1.0.3
Is defined by:
expression:
${helper.smtpPort}
default-value:
25
Is required.

username

protected String username
The username used to send the email.

Since:
1.0.3
Is defined by:
expression:
${helper.username}

password

protected String password
The password used to send the email.

Since:
1.0.3
Is defined by:
expression:
${helper.password}

sslMode

protected boolean sslMode
If the email should be sent in SSL mode.

Since:
1.0.3
Is defined by:
expression:
${helper.sslMode}
default-value:
false

fromDeveloperId

protected String fromDeveloperId
The id of the developer sending the announcement mail. Only used if the mailSender attribute is not set. In this case, this should match the id of one of the developers in the pom. If a matching developer is not found, then the first developer in the pom will be used.

Since:
1.0.3
Is defined by:
expression:
${helper.fromDeveloperId}

mailSender

protected MailSender mailSender
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.

Since:
1.0.3
Is defined by:
expression:
${helper.mailSender}

toAddresses

protected List<String> toAddresses
Recipient email address.

Since:
1.0.3
Is defined by:
Is required.

from

protected List<org.apache.maven.model.Developer> from
Possible senders.

Since:
1.0.3
Is defined by:
expression:
${project.developers}
Is readonly.
Is required.

mailContentType

protected String mailContentType
Mail content type to use.

Since:
1.0.3
Is defined by:
default-value:
text/plain
Is required.

encoding

protected String encoding
The encoding used to read and write files.

Since:
1.0.3
Is defined by:
expression:
${helper.encoding}
default-value:
${project.build.sourceEncoding}

skipSendEmail

protected boolean skipSendEmail
A flag to skip the goal.

Since:
1.0.3
Is defined by:
expression:
${helper.skipSendEmail}
default-value:
false

dryRun

protected boolean dryRun
A flag to test plugin but send nothing to redmine.

Since:
1.0.3
Is defined by:
expression:
${dryRun}
default-value:
false

runOnce

protected boolean runOnce
A flag to restirct only one run in a build (for multi-module context).

Since:
1.0.3
Is defined by:
expression:
${redmine.runOnce}
default-value:
true
Constructor Detail

SendEmailMojo

public SendEmailMojo()
Method Detail

getProject

public org.apache.maven.project.MavenProject getProject()

setProject

public void setProject(org.apache.maven.project.MavenProject project)

isVerbose

public boolean isVerbose()

setVerbose

public void setVerbose(boolean verbose)

init

protected void init()
             throws Exception
Description copied from class: AbstractPlugin
Method to initialize the mojo before doing any concrete actions.

Note: The method is invoked before the AbstractPlugin.doAction() method.

Specified by:
init in class AbstractPlugin
Throws:
Exception - if any

checkSkip

protected boolean checkSkip()
Description copied from class: AbstractPlugin
Checks if the mojo execution should be skipped.

Overrides:
checkSkip in class AbstractPlugin
Returns:
false if the mojo should not be executed.

doAction

protected void doAction()
                 throws Exception
Description copied from class: AbstractPlugin
Do plugin action.

The method AbstractPlugin.execute() invoke this method only and only if :

Specified by:
doAction in class AbstractPlugin
Throws:
Exception - if any

isGoalSkip

protected boolean isGoalSkip()

createMessage

protected org.codehaus.plexus.mailsender.MailMessage createMessage(String newsContent,
                                                                   MailSender mailSender)
                                                            throws org.codehaus.plexus.mailsender.MailSenderException
Throws:
org.codehaus.plexus.mailsender.MailSenderException

createMailer

protected ProjectJavamailMailSender createMailer()

setMailSender

public void setMailSender(MailSender mailSender)

setFrom

public void setFrom(List<org.apache.maven.model.Developer> from)

setToAddresses

public void setToAddresses(List<String> toAddresses)

isExecutionRoot

protected boolean isExecutionRoot()
Overrides:
isExecutionRoot in class AbstractPlugin
Returns:
true if project is the root execution project


Copyright © 2009-2010 CodeLutin. All Rights Reserved.