Author: tchemit Date: 2009-12-29 16:39:54 +0100 (Tue, 29 Dec 2009) New Revision: 641 Added: trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java trunk/src/main/java/org/nuiton/io/mail/ trunk/src/main/java/org/nuiton/io/mail/MailSender.java trunk/src/main/java/org/nuiton/io/mail/ProjectJavamailMailSender.java trunk/src/test/java/org/nuiton/helper/ trunk/src/test/java/org/nuiton/helper/plugin/ trunk/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java trunk/src/test/resources/org/nuiton/helper/ trunk/src/test/resources/org/nuiton/helper/plugin/ trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/ trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/mailContentFile.txt trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/sendEmail.xml trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/skipSendEmail.xml Removed: trunk/src/main/java/org/nuiton/mail/MailSender.java trunk/src/main/java/org/nuiton/mail/ProjectJavamailMailSender.java trunk/src/main/java/org/nuiton/mail/plugin/ trunk/src/test/java/org/nuiton/mail/ trunk/src/test/resources/org/nuiton/mail/ Modified: trunk/pom.xml trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java trunk/src/main/java/org/nuiton/helper/plugin/GenerateSiteIndexPlugin.java trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java trunk/src/main/java/org/nuiton/plugin/Plugin.java trunk/src/main/java/org/nuiton/plugin/PluginHelper.java Log: - begin of version 1.2.0 - improve AbstrctPlugin api : * init method does not anylonger returns anything just throw exception if something is wrong) * add a checkSkip method in api to make possible easely to not execute the doAction method * doAction method should not anylonger performs test form skipping content - use the new api on goals - move mail api to io.mail -move mail mojo to helper.plugin package (with other goals) Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/pom.xml 2009-12-29 15:39:54 UTC (rev 641) @@ -11,7 +11,7 @@ <groupId>org.nuiton</groupId> <artifactId>maven-helper-plugin</artifactId> - <version>1.1.1-SNAPSHOT</version> + <version>1.2.0-SNAPSHOT</version> <dependencies> Modified: trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java =================================================================== --- trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/helper/plugin/CollectFilesMojo.java 2009-12-29 15:39:54 UTC (rev 641) @@ -20,26 +20,22 @@ */ package org.nuiton.helper.plugin; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.nuiton.plugin.AbstractPlugin; +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + /** * Collect files some files from a project and copy them into a directory. * + * @author tchemit * @goal collect-files * @requiresProject true - * - * @author tchemit * @since 1.1.0 */ public class CollectFilesMojo extends AbstractPlugin { @@ -64,7 +60,7 @@ protected List attachedArtifacts; /** * User extra files to collect. - * + * <p/> * Multi values can be used, separated by comma. * * @parameter expression="${helper.extraFiles}" @@ -73,7 +69,7 @@ protected String extraFiles; /** * File name pattern of selected files to publish. - * + * <p/> * If no Set - no include filter * * @parameter expression="${helper.includes}" default-value="" @@ -82,7 +78,7 @@ protected String includes; /** * File name pattern of selected files to publish. - * + * <p/> * If no Set - no exclude filter * * @parameter expression="${helper.excludes}" default-value="" @@ -92,7 +88,7 @@ /** * Directory where to store collected files. * <p/> - * <b>Note :</b> In a multi-module context, will always use the value of + * <b>Note :</b> In a multi-module context, will always use the value of * the property of the root module, because we need to push collected files * to only one place. * @@ -152,18 +148,35 @@ * @since 1.0.0 */ protected String encoding; - List<File> files; + /** + * Files to collect + */ + protected List<File> files; @Override - protected boolean init() throws Exception { + protected void init() throws Exception { if (skip) { - return true; + return; } files = getFiles(); +// if (files.isEmpty()) { +// +// getLog().warn("No file to collect."); +// skip = true; +// } + } + + @Override + protected boolean checkSkip() { + if (skip) { + getLog().info("Skip flag is on, goal will not be executed."); + return false; + } + if (files.isEmpty()) { - getLog().warn("No file to collect."); + getLog().warn("No file to collect, goal will not be executed."); return false; } @@ -173,10 +186,10 @@ @Override public void doAction() throws Exception { - if (skip) { - getLog().info("Skip flag in on, goal will not be executed"); - return; - } +// if (skip) { +// getLog().info("Skip flag in on, goal will not be executed"); +// return; +// } MavenProject rootProject = getExecutionRootProject(); @@ -265,7 +278,7 @@ /** * Read a file containing on each line the path of a file. - * + * * @param input the file containing the list of files * @return the list of files read from the given file * @throws IOException if any pb while reading file @@ -289,7 +302,7 @@ * Each line is the absolute path of each files of the list * * @param output the file when to write - * @param files the files to store + * @param files the files to store * @throws IOException if any pb when writing file */ public void setFiles(File output, List<File> files) throws IOException { Modified: trunk/src/main/java/org/nuiton/helper/plugin/GenerateSiteIndexPlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/helper/plugin/GenerateSiteIndexPlugin.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/helper/plugin/GenerateSiteIndexPlugin.java 2009-12-29 15:39:54 UTC (rev 641) @@ -119,7 +119,8 @@ protected VelocityComponent velocity; @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { if (StringUtils.isEmpty(templateEncoding)) { templateEncoding = ReaderFactory.FILE_ENCODING; getLog().warn("File encoding has not been set, using platform encoding " + templateEncoding + ", i.e. build is platform dependent!"); @@ -131,7 +132,7 @@ defaultLocale = locales.substring(0, firstComma); } - return true; +// return true; } @Override Copied: trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java (from rev 640, trunk/src/main/java/org/nuiton/mail/plugin/SendEmailMojo.java) =================================================================== --- trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java (rev 0) +++ trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,426 @@ +/* + * *##% + * Maven helper plugin + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * ##%* + */ +package org.nuiton.helper.plugin; + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.model.Developer; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.project.MavenProject; +import org.apache.maven.settings.Settings; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.console.ConsoleLogger; +import org.codehaus.plexus.mailsender.MailMessage; +import org.codehaus.plexus.mailsender.MailSenderException; +import org.nuiton.io.mail.MailSender; +import org.nuiton.io.mail.ProjectJavamailMailSender; +import org.nuiton.plugin.AbstractPlugin; +import org.nuiton.plugin.PluginHelper; + +import java.io.File; +import java.util.List; + +/** + * Send a email. + * + * @author tchemit + * @goal send-email + * @requiresOnline true + * @requiresProject true + * @since 1.0.3 + */ +public class SendEmailMojo extends AbstractPlugin { + + /** + * Dependance du projet. + * + * @parameter default-value="${project}" + * @required + * @readonly + * @since 1.0.3 + */ + protected MavenProject project; + /** + * Dependance du settings. + * + * @parameter default-value="${settings}" + * @required + * @readonly + * @since 1.0.3 + */ + protected Settings settings; + /** + * Un flag pour activer le mode verbeux. + * + * @parameter expression="${helper.verbose}" default-value="${maven.verbose}" + * @since 1.0.3 + */ + protected boolean verbose; + /** + * The Velocity template used to format the email announcement. + * + * @parameter expression="${helper.emailContentFile}" + * @required + * @since 1.0.3 + */ + protected File emailContentFile; + /** + * The title of the email to send. + * + * @parameter expression="${helper.emailTitle}" + * @required + * @since 1.0.3 + */ + protected String emailTitle; + /** + * Smtp Server. + * + * @parameter expression="${helper.smtpHost}" + * @required + * @since 1.0.3 + */ + protected String smtpHost; + /** + * Port. + * + * @parameter default-value="25" expression="${helper.smtpPort}" + * @required + * @since 1.0.3 + */ + protected int smtpPort; + /** + * The username used to send the email. + * + * @parameter expression="${helper.username}" + * @since 1.0.3 + */ + protected String username; + /** + * The password used to send the email. + * + * @parameter expression="${helper.password}" + * @since 1.0.3 + */ + protected String password; + /** + * If the email should be sent in SSL mode. + * + * @parameter default-value="false" expression="${helper.sslMode}" + * @since 1.0.3 + */ + protected boolean sslMode; + /** + * The id of the developer sending the announcement mail. Only used if the <tt>mailSender</tt> + * 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. + * + * @parameter expression="${helper.fromDeveloperId}" + * @since 1.0.3 + */ + protected String fromDeveloperId; + /** + * 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. + * + * @parameter expression="${helper.mailSender}" + * @since 1.0.3 + */ + protected MailSender mailSender; + /** + * Recipient email address. + * + * @parameter + * @required + * @since 1.0.3 + */ + protected List<String> toAddresses; + /** + * Possible senders. + * + * @parameter expression="${project.developers}" + * @required + * @readonly + * @since 1.0.3 + */ + protected List<Developer> from; + /** + * Mail content type to use. + * + * @parameter default-value="text/plain" + * @required + * @since 1.0.3 + */ + protected String mailContentType; + /** + * The encoding used to read and write files. + * + * @parameter expression="${helper.encoding}" default-value="${project.build.sourceEncoding}" + * @since 1.0.3 + */ + protected String encoding; + /** + * A flag to skip the goal. + * + * @parameter expression="${helper.skipSendEmail}" default-value="false" + * @since 1.0.3 + */ + private boolean skipSendEmail; + /** + * A flag to test plugin but send nothing to redmine. + * + * @parameter expression="${dryRun}" default-value="false" + * @since 1.0.3 + */ + protected boolean dryRun; + /** + * A flag to restirct only one run in a build (for multi-module context). + * + * @parameter expression="${redmine.runOnce}" default-value="true" + * @since 1.0.3 + */ + private boolean runOnce; + /** + * internal flag to know if plugin was already executed (for multi-module projects) + */ + private boolean runOnceDone; + /////////////////////////////////////////////////////////////////////////// + /// Plugin + /////////////////////////////////////////////////////////////////////////// + + @Override + public MavenProject getProject() { + return project; + } + + @Override + public void setProject(MavenProject project) { + this.project = project; + } + + @Override + public boolean isVerbose() { + return verbose; + } + + @Override + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + /////////////////////////////////////////////////////////////////////////// + /// AbstractPlugin + /////////////////////////////////////////////////////////////////////////// + @Override + protected void init() throws Exception { +// protected boolean init() throws Exception { + + if (isGoalSkip()) { + return; +// return true; + } + + runOnceDone = false; + if (runOnce) { + // check + + if (!isExecutionRoot()) { +// getLog().info("runOnce flag is on, will skip the goal"); + runOnceDone = true; + return; +// return true; + } + } + + if (!emailContentFile.exists()) { + // no file to publish... + throw new MojoExecutionException("could not find the template " + emailContentFile); +// getLog().warn("could not find the template " + emailContentFile); +// getLog().warn("will skip send email..."); +// return false; + } + + // check mail sender + + if (mailSender == null) { + + if (from == null || from.isEmpty()) { + throw new MojoExecutionException("The <developers> section in your pom should not be empty. Add a <developer> entry or set the " + "mailSender parameter."); +// getLog().warn("The <developers> section in your pom should not be empty. Add a <developer> entry or set the " + "mailSender parameter."); +// getLog().warn("will skip send email..."); +// return false; + } + + if (fromDeveloperId == null) { + final Developer dev = from.get(0); + mailSender = new MailSender(dev.getName(), dev.getEmail()); + } else { + for (Developer developer : from) { + if (fromDeveloperId.equals(developer.getId())) { + mailSender = new MailSender(developer.getName(), developer.getEmail()); + break; + } + } + if (mailSender == null) { + throw new MojoExecutionException("Missing developer with id '" + fromDeveloperId + "' in the <developers> section in your pom."); +// getLog().warn("Missing developer with id '" + fromDeveloperId + "' in the <developers> section in your pom."); +// getLog().warn("will skip send email..."); +// return false; + } + } + } + + String fromAddress = mailSender.getEmail(); + if (StringUtils.isEmpty(fromAddress)) { + throw new MojoExecutionException("Invalid mail sender: name and email is mandatory (" + mailSender + ")."); +// getLog().warn("Invalid mail sender: name and email is mandatory (" + mailSender + ")."); +// getLog().warn("will skip send email..."); +// return false; + } + +// return true; + } + + @Override + protected boolean checkSkip() { + if (isGoalSkip()) { + // goal mark to be skipped + getLog().info("skipGoal flag is on, will skip the goal."); + return false; + } + + if (runOnce && runOnceDone) { + // already run + getLog().info("runOnce flag is on and goal was laready executed, will skip the goal"); + + return false; + } + + return true; + } + + @Override + protected void doAction() throws Exception { +// if (runOnce && runOnceDone) { +// // already run +// return; +// } +// if (isGoalSkip()) { +// getLog().info("skipGoal flag is on, the goal is skip."); +// return; +// } + + if (dryRun) { + getLog().info("\n dryRun flag is on, no mail will be send!\n"); + } + + String newsContent = PluginHelper.readAsString(emailContentFile, encoding); + + MailMessage mailMsg = createMessage(newsContent, mailSender); + + + ProjectJavamailMailSender mailer = createMailer(); + + if (getLog().isDebugEnabled()) { + getLog().debug("fromDeveloperId: " + fromDeveloperId); + } + + if (dryRun) { + getLog().info("Mail title : " + emailTitle); + getLog().info("Mail content :\n" + mailMsg.getContent()); + return; + } + getLog().info("Connecting to Host: " + smtpHost + ":" + smtpPort); + + try { + + mailer.send(mailMsg); + getLog().info("Sent..."); + } catch (MailSenderException e) { + throw new MojoExecutionException("Failed to send email for reason " + e.getMessage(), e); + } + } + + /////////////////////////////////////////////////////////////////////////// + /// Other + /////////////////////////////////////////////////////////////////////////// + protected boolean isGoalSkip() { + return skipSendEmail; + } + + protected MailMessage createMessage(String newsContent, MailSender mailSender) throws MailSenderException { + + String fromName = mailSender.getName(); + String fromAddress = mailSender.getEmail(); + + getLog().info("Using this sender for email announcement: " + fromAddress + " < " + fromName + " > "); + + MailMessage mailMsg = new MailMessage(); + mailMsg.setSubject(emailTitle); + if (getLog().isDebugEnabled()) { + getLog().debug("email announcement :\n" + newsContent); + } + mailMsg.setContent(newsContent); + mailMsg.setContentType(mailContentType); + mailMsg.setFrom(fromAddress, fromName); + for (String e : toAddresses) { + getLog().info("Sending mail to " + e + "..."); + mailMsg.addTo(e, ""); + } + return mailMsg; + } + + protected ProjectJavamailMailSender createMailer() { + + ProjectJavamailMailSender mailer = new ProjectJavamailMailSender(); + ConsoleLogger logger = new ConsoleLogger(Logger.LEVEL_INFO, "base"); + if (getLog().isDebugEnabled()) { + logger.setThreshold(Logger.LEVEL_DEBUG); + } + mailer.enableLogging(logger); + mailer.setSmtpHost(smtpHost); + mailer.setSmtpPort(smtpPort); + mailer.setSslMode(sslMode); + if (username != null) { + mailer.setUsername(username); + } + if (password != null) { + mailer.setPassword(password); + } + mailer.initialize(); + return mailer; + } + + public void setMailSender(MailSender sender) { + this.mailSender = sender; + } + + public void setFrom(List<Developer> from) { + this.from = from; + } + + public void setToAddresses(List<String> toAddresses) { + this.toAddresses = toAddresses; + } + + protected boolean isExecutionRoot() { + return project.isExecutionRoot(); + } +} Property changes on: trunk/src/main/java/org/nuiton/helper/plugin/SendEmailMojo.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/helper/plugin/ShareServerSecretPlugin.java 2009-12-29 15:39:54 UTC (rev 641) @@ -1,6 +1,7 @@ package org.nuiton.helper.plugin; import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; @@ -153,7 +154,8 @@ } @Override - protected boolean init() throws Exception { + protected void init() throws Exception { +// protected boolean init() throws Exception { propertiesToTreate = new EnumMap<Property, String>(Property.class); @@ -170,23 +172,27 @@ propertiesToTreate.put(Property.privateKey, privateKeyOut); } if (propertiesToTreate.isEmpty()) { - getLog().error("Nothing to export, you should specify what to export via 'usernameOut', 'passwordOut', 'passphraseOut', 'privateKeyOut' parameters."); - return false; + throw new MojoExecutionException("Nothing to export, you should specify what to export via 'usernameOut', 'passwordOut', 'passphraseOut' or 'privateKeyOut' parameters."); +// +// getLog().error("Nothing to export, you should specify what to export via 'usernameOut', 'passwordOut', 'passphraseOut', 'privateKeyOut' parameters."); +// return false; } if (StringUtils.isEmpty(serverId)) { - getLog().error("No 'serverId' defined."); - return false; + throw new MojoExecutionException("No 'serverId' defined."); +// getLog().error("No 'serverId' defined."); +// return false; } server = settings.getServer(serverId.trim()); if (server == null) { - getLog().error("Could not find server with id '" + serverId + "', check your settings.xml file."); - return false; + throw new MojoExecutionException("Could not find server with id '" + serverId + "', check your settings.xml file."); +// getLog().error("Could not find server with id '" + serverId + "', check your settings.xml file."); +// return false; } - return true; +// return true; } @Override @@ -199,6 +205,9 @@ String propertyValue = key.getSecret(server); String propertyTargetName = entry.getValue(); + if (isVerbose()) { + getLog().info("will decrypt [" + key + "] : " + propertyValue); + } propertyValue = sec.decrypt(propertyValue); getLog().info("export server [" + serverId + "] " + key.name() + " in ${" + propertyTargetName + "}"); Copied: trunk/src/main/java/org/nuiton/io/mail/MailSender.java (from rev 640, trunk/src/main/java/org/nuiton/mail/MailSender.java) =================================================================== --- trunk/src/main/java/org/nuiton/io/mail/MailSender.java (rev 0) +++ trunk/src/main/java/org/nuiton/io/mail/MailSender.java 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,66 @@ +/* + * *##% + * Maven helper plugin + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * ##%* + */ +package org.nuiton.io.mail; + +/** + * Defines the sender of a email. + * + * Note : this code was stolen in {@code maven-changes-plugin}, should thanks + * them... + * + * @author chemit + * @since 1.0.3 + */ +public class MailSender { + + private String name; + private String email; + + public MailSender() { + super(); + } + + public MailSender(String name, String email) { + this.name = name; + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + return getName() + " (" + getEmail() + ")"; + } +} Property changes on: trunk/src/main/java/org/nuiton/io/mail/MailSender.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Copied: trunk/src/main/java/org/nuiton/io/mail/ProjectJavamailMailSender.java (from rev 640, trunk/src/main/java/org/nuiton/mail/ProjectJavamailMailSender.java) =================================================================== --- trunk/src/main/java/org/nuiton/io/mail/ProjectJavamailMailSender.java (rev 0) +++ trunk/src/main/java/org/nuiton/io/mail/ProjectJavamailMailSender.java 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,182 @@ +/* + * *##% + * Maven helper plugin + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * ##%* + */ +package org.nuiton.io.mail; + +import java.security.Security; +import java.util.Date; +import java.util.Iterator; +import java.util.Properties; + +import javax.mail.Authenticator; +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.PasswordAuthentication; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + +import org.codehaus.plexus.mailsender.AbstractMailSender; +import org.codehaus.plexus.mailsender.MailMessage; +import org.codehaus.plexus.mailsender.MailSenderException; +import org.codehaus.plexus.mailsender.util.DateFormatUtils; +import org.codehaus.plexus.util.StringUtils; + +/** + * Helper class for sending email. + * + * Note : this code was stolen in {@code maven-changes-plugin}, should thanks + * them... + * + * @author chemit + * @since 1.0.3 + */ +public class ProjectJavamailMailSender + extends AbstractMailSender { + + private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + private Properties userProperties; + private Properties props; + + // ---------------------------------------------------------------------- + // Component Lifecycle + // ---------------------------------------------------------------------- + public void initialize() { + if (StringUtils.isEmpty(getSmtpHost())) { + System.out.println("Error in configuration: Missing smtpHost."); + } + + if (getSmtpPort() == 0) { + setSmtpPort(DEFAULT_SMTP_PORT); + } + + props = new Properties(); + + props.put("mail.smtp.host", getSmtpHost()); + + props.put("mail.smtp.port", String.valueOf(getSmtpPort())); + + if (getUsername() != null) { + props.put("mail.smtp.auth", "true"); + } + + props.put("mail.debug", String.valueOf(getLogger().isDebugEnabled())); + + if (isSslMode()) { + Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); + + props.put("mail.smtp.socketFactory.port", String.valueOf(getSmtpPort())); + + props.put("mail.smtp.socketFactory.class", SSL_FACTORY); + + props.put("mail.smtp.socketFactory.fallback", "false"); + } + + if (userProperties != null) { + for (Iterator<?> i = userProperties.keySet().iterator(); i.hasNext();) { + String key = (String) i.next(); + + String value = userProperties.getProperty(key); + + props.put(key, value); + } + } + } + + // ---------------------------------------------------------------------- + // MailSender Implementation + // ---------------------------------------------------------------------- + @Override + public void send(MailMessage mail) + throws MailSenderException { + verify(mail); + + try { + Authenticator auth = null; + + if (getUsername() != null) { + auth = new Authenticator() { + + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(getUsername(), getPassword()); + } + }; + } + + Session session = Session.getDefaultInstance(props, auth); + + session.setDebug(getLogger().isDebugEnabled()); + + Message msg = new MimeMessage(session); + InternetAddress addressFrom = new InternetAddress(mail.getFrom().getRfc2822Address()); + msg.setFrom(addressFrom); + + if (mail.getToAddresses().size() > 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(), mail.getContentType() == null ? "text/plain" : mail.getContentType()); + + 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); + } + } +} Property changes on: trunk/src/main/java/org/nuiton/io/mail/ProjectJavamailMailSender.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Deleted: trunk/src/main/java/org/nuiton/mail/MailSender.java =================================================================== --- trunk/src/main/java/org/nuiton/mail/MailSender.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/mail/MailSender.java 2009-12-29 15:39:54 UTC (rev 641) @@ -1,66 +0,0 @@ -/* - * *##% - * Maven helper plugin - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * ##%* - */ -package org.nuiton.mail; - -/** - * Defines the sender of a email. - * - * Note : this code was stolen in {@code maven-changes-plugin}, should thanks - * them... - * - * @author chemit - * @since 1.0.3 - */ -public class MailSender { - - private String name; - private String email; - - public MailSender() { - super(); - } - - public MailSender(String name, String email) { - this.name = name; - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - @Override - public String toString() { - return getName() + " (" + getEmail() + ")"; - } -} Deleted: trunk/src/main/java/org/nuiton/mail/ProjectJavamailMailSender.java =================================================================== --- trunk/src/main/java/org/nuiton/mail/ProjectJavamailMailSender.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/mail/ProjectJavamailMailSender.java 2009-12-29 15:39:54 UTC (rev 641) @@ -1,182 +0,0 @@ -/* - * *##% - * Maven helper plugin - * Copyright (C) 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * ##%* - */ -package org.nuiton.mail; - -import java.security.Security; -import java.util.Date; -import java.util.Iterator; -import java.util.Properties; - -import javax.mail.Authenticator; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.PasswordAuthentication; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - -import org.codehaus.plexus.mailsender.AbstractMailSender; -import org.codehaus.plexus.mailsender.MailMessage; -import org.codehaus.plexus.mailsender.MailSenderException; -import org.codehaus.plexus.mailsender.util.DateFormatUtils; -import org.codehaus.plexus.util.StringUtils; - -/** - * Helper class for sending email. - * - * Note : this code was stolen in {@code maven-changes-plugin}, should thanks - * them... - * - * @author chemit - * @since 1.0.3 - */ -public class ProjectJavamailMailSender - extends AbstractMailSender { - - private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - private Properties userProperties; - private Properties props; - - // ---------------------------------------------------------------------- - // Component Lifecycle - // ---------------------------------------------------------------------- - public void initialize() { - if (StringUtils.isEmpty(getSmtpHost())) { - System.out.println("Error in configuration: Missing smtpHost."); - } - - if (getSmtpPort() == 0) { - setSmtpPort(DEFAULT_SMTP_PORT); - } - - props = new Properties(); - - props.put("mail.smtp.host", getSmtpHost()); - - props.put("mail.smtp.port", String.valueOf(getSmtpPort())); - - if (getUsername() != null) { - props.put("mail.smtp.auth", "true"); - } - - props.put("mail.debug", String.valueOf(getLogger().isDebugEnabled())); - - if (isSslMode()) { - Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); - - props.put("mail.smtp.socketFactory.port", String.valueOf(getSmtpPort())); - - props.put("mail.smtp.socketFactory.class", SSL_FACTORY); - - props.put("mail.smtp.socketFactory.fallback", "false"); - } - - if (userProperties != null) { - for (Iterator<?> i = userProperties.keySet().iterator(); i.hasNext();) { - String key = (String) i.next(); - - String value = userProperties.getProperty(key); - - props.put(key, value); - } - } - } - - // ---------------------------------------------------------------------- - // MailSender Implementation - // ---------------------------------------------------------------------- - @Override - public void send(MailMessage mail) - throws MailSenderException { - verify(mail); - - try { - Authenticator auth = null; - - if (getUsername() != null) { - auth = new Authenticator() { - - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(getUsername(), getPassword()); - } - }; - } - - Session session = Session.getDefaultInstance(props, auth); - - session.setDebug(getLogger().isDebugEnabled()); - - Message msg = new MimeMessage(session); - InternetAddress addressFrom = new InternetAddress(mail.getFrom().getRfc2822Address()); - msg.setFrom(addressFrom); - - if (mail.getToAddresses().size() > 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(), mail.getContentType() == null ? "text/plain" : mail.getContentType()); - - 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); - } - } -} Modified: trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java =================================================================== --- trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/plugin/AbstractPlugin.java 2009-12-29 15:39:54 UTC (rev 641) @@ -49,13 +49,15 @@ * <p/> * <b>Note:</b> The method is invoked before the {@link #doAction()} method. * <p/> + * <p/> + * // * @return <code>true</code> if mojo is well initialize and something has + * // * to be done in the {@link #doAction()} method, <code>false</code> + * // * otherwise. * - * @return <code>true</code> if mojo is well initialize and something has - * to be done in the {@link #doAction()} method, <code>false</code> - * otherwise. * @throws Exception if any */ - protected abstract boolean init() throws Exception; + protected abstract void init() throws Exception; +// protected abstract boolean init() throws Exception; /** * Do plugin action. @@ -70,41 +72,54 @@ */ protected abstract void doAction() throws Exception; - /** - * the message to display when will skip the goal - */ - protected String skipAfterInitMessage; +// /** +// * the message to display when will skip the goal +// */ +// protected String skipAfterInitMessage; - protected AbstractPlugin() { - this("The goal could not be initialized, will skip the goal"); - } +// protected AbstractPlugin() { +// this("The goal could not be initialized, will skip the goal"); +// } - protected AbstractPlugin(String skipAfterInitMessage) { - this.skipAfterInitMessage = skipAfterInitMessage; - } +// protected AbstractPlugin(String skipAfterInitMessage) { +// this.skipAfterInitMessage = skipAfterInitMessage; +// } @Override - public void execute() throws MojoExecutionException, MojoFailureException { + public final void execute() throws MojoExecutionException, MojoFailureException { + // check if project packaging is compatible with the mojo + boolean canContinue = checkPackaging(); if (!canContinue) { getLog().warn("The goal is skip due to packaging '" + getProject().getPackaging() + "'"); return; } + // init the mojo + try { - canContinue = init(); + init(); +// canContinue = init(); } catch (Exception e) { throw new MojoExecutionException("could not init goal " + getClass().getSimpleName() + " for reason : " + e.getMessage(), e); } + // check if mojo can be skipped + + canContinue = checkSkip(); if (!canContinue) { - getLog().warn(skipAfterInitMessage); + if (isVerbose() || getLog().isDebugEnabled()) { + getLog().info("Goal will not be executed."); + } +// getLog().warn(skipAfterInitMessage); return; } + // can really execute the mojo + try { doAction(); @@ -134,14 +149,25 @@ * project, {@code false} otherwise. */ protected boolean checkPackaging() { + // by default, accept every type of packaging return true; } /** + * Checks if the mojo execution should be skipped. + * + * @return {@code false} if the mojo should not be executed. + */ + protected boolean checkSkip() { + // by default, never skip goal + return true; + } + + /** * Accept the project's packaging between some given. * * @param packages the accepted packaging - * @return {@code true} if the project's packagin is one of the given ones. + * @return {@code true} if the project's packaging is one of the given ones. */ protected boolean acceptPackaging(Packaging... packages) { String projectPackaging = getProject().getPackaging(); @@ -252,19 +278,18 @@ * * @param srcFile represents the file to copy. * @param destFile file name of destination file. - * @throws MojoExecutionException with a message if an - * error occurs. + * @throws IOException if could not copy file. */ public void copyFile(File srcFile, File destFile) - throws MojoExecutionException { - try { - getLog().info("Copying " + srcFile.getName() + " to " + destFile); + throws IOException { +// try { + getLog().info("Copying " + srcFile.getName() + " to " + destFile); - PluginHelper.copy(srcFile, destFile); + PluginHelper.copy(srcFile, destFile); - } catch (Exception e) { - throw new MojoExecutionException("Error copying from " + srcFile + " to " + destFile, e); - } +// } catch (Exception e) { +// throw new MojoExecutionException("Error copying from " + srcFile + " to " + destFile, e); +// } } /** @@ -586,6 +611,26 @@ } /** + * @param file the source file + * @return the backup file + */ + public File getBackupFile(File file) { + return new File(file.getAbsolutePath() + "~"); + } + + /** + * Backups the given file using the {@link #getBackupFile(java.io.File)} as + * destination file. + * + * @param f the file to backup + * @throws IOException if any pb while copying the file + */ + protected void backupFile(File f) throws IOException { + File dst = getBackupFile(f); + copyFile(f, dst); + } + + /** * Init mojo classLoader. * * @param project the maven project Modified: trunk/src/main/java/org/nuiton/plugin/Plugin.java =================================================================== --- trunk/src/main/java/org/nuiton/plugin/Plugin.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/plugin/Plugin.java 2009-12-29 15:39:54 UTC (rev 641) @@ -25,15 +25,33 @@ /** * A common contract to be implements by our mojo and reports. + * <p/> + * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}. * - * Just expose a {@link #isVerbose()} flag and the maven project {@link #getProject()}. - * * @author chemit * @since 1.0.3 */ public interface Plugin extends Mojo { /** + * An enumeration to qualify the init result of a plugin + */ + enum InitState { + /** + * when something is wrong and should throw an error + */ + failed, + /** + * when the plugin execution should be skipped + */ + skip, + /** + * when plugin can be executed + */ + ok + } + + /** * An enumeration to qualify a maven module packaging */ enum Packaging { @@ -43,8 +61,10 @@ plugin, war, ear - }; + } + ; + MavenProject getProject(); void setProject(MavenProject project); Modified: trunk/src/main/java/org/nuiton/plugin/PluginHelper.java =================================================================== --- trunk/src/main/java/org/nuiton/plugin/PluginHelper.java 2009-12-28 09:27:41 UTC (rev 640) +++ trunk/src/main/java/org/nuiton/plugin/PluginHelper.java 2009-12-29 15:39:54 UTC (rev 641) @@ -20,32 +20,19 @@ */ package org.nuiton.plugin; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - import org.apache.maven.model.Resource; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; +import java.io.*; +import java.text.MessageFormat; +import java.util.*; +import java.util.Map.Entry; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + /** * Une classe pour mutualiser toutes les méthodes utiles pour un plugin. * @@ -269,7 +256,7 @@ /** * @param newresourceDir the new resource directory to add - * @param project the maven project to modifiy + * @param project the maven project to modifiy * @return {@code true} if resources was added * @deprecated since 1.1.1, prefer use the {@link #addResourceDir(java.io.File, org.apache.maven.project.MavenProject, String...)} */ @@ -282,7 +269,7 @@ /** * @param newresourceDir the new resource directory to add - * @param project the maven project to modifiy + * @param project the maven project to modifiy * @return {@code true} if resources was added * @deprecated since 1.1.1, prefer use the {@link #addTestResourceDir(java.io.File, org.apache.maven.project.MavenProject, String...)} */ @@ -295,8 +282,8 @@ /** * @param newresourceDir the new resource directory to add - * @param project the maven project to modifiy - * @param resources the known resources for the maven project + * @param project the maven project to modifiy + * @param resources the known resources for the maven project * @return {@code true} if resources was added * @deprecated since 1.1.1, prefer use the {@link #addResourceDir(java.io.File, org.apache.maven.project.MavenProject, java.util.List, String...)} */ @@ -365,6 +352,10 @@ * @since 1.1.1 */ public static void deleteFile(File file) throws IOException { + if (!file.exists()) { + // file does not exist, can not delete it + return; + } boolean b = file.delete(); if (!b) { throw new IOException("could not delete file " + file); Copied: trunk/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java (from rev 640, trunk/src/test/java/org/nuiton/mail/plugin/SendEmailMojoTest.java) =================================================================== --- trunk/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java (rev 0) +++ trunk/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,88 @@ +/* + * *##% + * Maven helper plugin + * Copyright (C) 2009 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * ##%* + */ +package org.nuiton.helper.plugin; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.nuiton.io.mail.MailSender; +import org.nuiton.plugin.AbstractMojoTest; + +import java.io.File; +import java.util.Arrays; + +/** + * @author tchemit + * @since 1.0.0 + */ +public class SendEmailMojoTest extends AbstractMojoTest<SendEmailMojo> { + + protected boolean canContinue; + + @Override + protected String getGoalName(String methodName) { + return "send-email"; + } + + @Override + protected void setUpMojo(SendEmailMojo mojo, File pomFile) throws Exception { + super.setUpMojo(mojo, pomFile); + + // add a mailSender here + MailSender sender = new MailSender(); + sender.setName("Nuiton Release Notification"); + sender.setEmail("test@noway.fr"); + mojo.setMailSender(sender); + + // add a destination + mojo.setToAddresses(Arrays.asList("chemit@codelutin.com")); + + try { + mojo.init(); + canContinue = true; + } catch (Exception e) { + canContinue = false; + } +// canContinue = mojo.init(); + if (canContinue) { + if (mojo.isVerbose()) { + log.info("setup done for " + mojo.getProject().getFile().getName()); + } + } else { + log.error("setup was not successfull, will skip this test [" + getClass() + "]"); + } + } + + @Test + public void sendEmail() throws Exception { + Assume.assumeTrue(canContinue); + + Assert.assertNotNull(getMojo()); + getMojo().doAction(); + } + + @Test + public void skipSendEmail() throws Exception { + Assume.assumeTrue(canContinue); + Assert.assertNotNull(getMojo()); + getMojo().execute(); + } +} Property changes on: trunk/src/test/java/org/nuiton/helper/plugin/SendEmailMojoTest.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Copied: trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/mailContentFile.txt (from rev 640, trunk/src/test/resources/org/nuiton/mail/plugin/sendEmailMojoTest/mailContentFile.txt) =================================================================== --- trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/mailContentFile.txt (rev 0) +++ trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/mailContentFile.txt 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1 @@ +The content of the test email \ No newline at end of file Copied: trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/sendEmail.xml (from rev 640, trunk/src/test/resources/org/nuiton/mail/plugin/sendEmailMojoTest/sendEmail.xml) =================================================================== --- trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/sendEmail.xml (rev 0) +++ trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/sendEmail.xml 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.test</groupId> + <artifactId>test-send-email</artifactId> + <version>0</version> + + <build> + + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <configuration> + <emailContentFile>target/test-classes/org/nuiton/mail/plugin/sendEmailMojoTest/mailContentFile.txt</emailContentFile> + <emailTitle>[ANNOUNCEMENT] - One 1.0.0 released</emailTitle> + <encoding>UTF-8</encoding> + <skipSendEmail>false</skipSendEmail> + <!--<mailSender> + <name>Nuiton Release Notification</name> + <email>noreply@${platform}</email> + </mailSender> + <toAddresses> + <item>chemit@codelutin.com</item> + </toAddresses>--> + <smtpHost>smtp</smtpHost> + <smtpPort>25</smtpPort> + <dryRun>true</dryRun> + </configuration> + <executions> + <execution> + <goals> + <goal>send-email</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file Copied: trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/skipSendEmail.xml (from rev 640, trunk/src/test/resources/org/nuiton/mail/plugin/sendEmailMojoTest/skipSendEmail.xml) =================================================================== --- trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/skipSendEmail.xml (rev 0) +++ trunk/src/test/resources/org/nuiton/helper/plugin/sendEmailMojoTest/skipSendEmail.xml 2009-12-29 15:39:54 UTC (rev 641) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>org.nuiton.test</groupId> + <artifactId>test-send-email</artifactId> + <version>0</version> + + <build> + + <plugins> + <plugin> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <configuration> + <emailContentFile>target/test-classes/org/nuiton/smail/plugin/sendEmailMojoTest/mailContentFile.txt</emailContentFile> + <emailTitle>[ANNOUNCEMENT] - One 1.0.0 released</emailTitle> + <encoding>UTF-8</encoding> + <skipSendEmail>true</skipSendEmail> + </configuration> + <executions> + <execution> + <goals> + <goal>send-email</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file