Author: tchemit Date: 2009-09-19 18:31:30 +0200 (Sat, 19 Sep 2009) New Revision: 186 Removed: jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/CollectFilesMojo.java jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/SendEmailMojo.java jredmine/trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/SendEmailMojoTest.java jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/mailContentFile.txt jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/sendEmail.xml jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/skipSendEmail.xml Modified: jredmine/trunk/ jredmine/trunk/jredmine-client/pom.xml jredmine/trunk/maven-jredmine-plugin/ jredmine/trunk/maven-jredmine-plugin/pom.xml jredmine/trunk/pom.xml Log: deplacements des goal generiques send-email et collect-files vers maven-helper-plugin Property changes on: jredmine/trunk ___________________________________________________________________ Added: svn:ignore + target Modified: jredmine/trunk/jredmine-client/pom.xml =================================================================== --- jredmine/trunk/jredmine-client/pom.xml 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/jredmine-client/pom.xml 2009-09-19 16:31:30 UTC (rev 186) @@ -61,10 +61,10 @@ </exclusions> </dependency> - <dependency> + <!-- <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - </dependency> + </dependency>--> <dependency> <groupId>log4j</groupId> @@ -73,16 +73,16 @@ </dependency> <!-- fix dependency in xpp parsing from plexus (need at least version > 2.2) --> - <dependency> + <!--<dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> - </dependency> + </dependency>--> <!-- fix dependency in maven-helper-plugin --> - <dependency> + <!--<dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> - </dependency> + </dependency>--> <dependency> <groupId>junit</groupId> Property changes on: jredmine/trunk/maven-jredmine-plugin ___________________________________________________________________ Added: svn:ignore + target Modified: jredmine/trunk/maven-jredmine-plugin/pom.xml =================================================================== --- jredmine/trunk/maven-jredmine-plugin/pom.xml 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/pom.xml 2009-09-19 16:31:30 UTC (rev 186) @@ -39,10 +39,10 @@ </dependency> <!-- fix dependency pb in velocity (need at least version > 2.2) --> - <dependency> + <!-- <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> - </dependency> + </dependency>--> <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> <dependency> @@ -73,6 +73,22 @@ <dependency> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changes-plugin</artifactId> + <!--<exclusions> + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-simple</artifactId> + </exclusion> + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-api</artifactId> + </exclusion> + + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-javamail</artifactId> + </exclusion> + + </exclusions>--> </dependency> <dependency> @@ -81,10 +97,10 @@ <scope>compile</scope> </dependency> - <dependency> + <!-- <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> - </dependency> + </dependency>--> <!-- tests dependencies --> Deleted: jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/CollectFilesMojo.java =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/CollectFilesMojo.java 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/CollectFilesMojo.java 2009-09-19 16:31:30 UTC (rev 186) @@ -1,325 +0,0 @@ -package org.nuiton.jredmine.plugin; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.regex.Pattern; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.FileUtils; - -/** - * Collect files some files from a project and copy them into a directory. - * - * @goal collect-files - * @requiresProject true - * - * @author tchemit - * @since 1.0.3 - */ -public class CollectFilesMojo extends AbstractMojo { - - /** - * @parameter expression="${session}" - * @required - * @readonly - */ - private MavenSession mavenSession; - /** - * Dependance du projet. - * - * @parameter default-value="${project}" - * @required - * @readonly - * @since 1.0.3 - */ - protected MavenProject project; - /** - * The artifacts to publish from the project build. - * - * @parameter expression="${project.attachedArtifacts}" - * @required - * @readonly - * @since 1.0.0 - */ - protected List attachedArtifacts; - /** - * User extra files to collect. - * - * Multi values can be used, separated by comma. - * - * @parameter expression="${helper.extraFiles}" - * @since 1.0.0 - */ - protected String extraFiles; - /** - * File name pattern of selected files to publish. - * - * If no Set - no include filter - * - * @parameter expression="${helper.includes}" default-value="" - * @since 1.0.0 - */ - protected String includes; - /** - * File name pattern of selected files to publish. - * - * If no Set - no exclude filter - * - * @parameter expression="${helper.excludes}" default-value="" - * @since 1.0.0 - */ - protected String excludes; - /** - * Directory where to store collected files. - * <p/> - * <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. - * - * @parameter expression="${helper.outputDirectory}" default-value="target/collect" - * @since 1.0.0 - */ - protected String outputDirectory; - /** - * Properties file will all files collected indexed by their path. - * <p/> - * <b>Note :</b> If not Set, will not generate the description file. - * - * @parameter expression="${helper.descriptionFile}" - * @since 1.0.0 - */ - protected String descriptionFile; - /** - * Un flag pour collecter aussi les fichiers attaches au projet. - * - * @parameter expression="${helper.includeAttached}" default-value="true" - * @since 1.0.0 - */ - protected boolean includeAttached; - /** - * Un flag pour recopier les fichiers collectés. - * - * @parameter expression="${helper.copyFiles}" default-value="true" - * @since 1.0.0 - */ - protected boolean copyFiles; - /** - * Un flag pour activer le mode verbeux. - * - * @parameter expression="${helper.verbose}" default-value="${maven.verbose}" - * @since 1.0.0 - */ - protected boolean verbose; - /** - * A flag to skip the goal. - * - * @parameter expression="${helper.skip}" default-value="false" - * @since 1.0.0 - */ - protected boolean skip; - /** - * Un flag pour activer le mode verbeux. - * - * @parameter expression="${helper.dryRun}" default-value="false" - * @since 1.0.0 - */ - protected boolean dryRun; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - - if (skip) { - getLog().info("Skip flag in on, goal will not be executed"); - } - List<File> files = getFiles(); - if (files.isEmpty()) { - - getLog().warn("No files to collect."); - return; - } - - MavenProject rootProject = getExecutionRootProject(); - - File base = new File(rootProject.getBasedir(), outputDirectory); - - File output = new File(base, project.getGroupId() + "--" + project.getArtifactId()); - - if (rootProject == project || verbose) { - // just print on root - getLog().info("Ouput dir : " + output); - } - - if (dryRun) { - getLog().info("\n dryRun flag is on, no file will be copied!\n"); - } else { - - if (!output.exists()) { - output.mkdirs(); - } - } - - File description = null; - - Properties p = new Properties(); - boolean withDescriptionFile = false; - if (descriptionFile != null && !descriptionFile.trim().isEmpty()) { - - description = new File(rootProject.getBasedir(), descriptionFile); - - withDescriptionFile = true; - - if (description.exists()) { - // reload existing - try { - p.load(new FileInputStream(description)); - getLog().info("Load " + description); - } catch (IOException ex) { - throw new MojoExecutionException("could not load file " + description, ex); - } - } - } - - if (!withDescriptionFile && !copyFiles) { - throw new MojoExecutionException("must use at least one of the parameters 'copyFiles' or 'descriptionFile'"); - } - - String basedir = rootProject.getBasedir().getAbsolutePath(); - int basedirLength = basedir.length(); - for (File f : files) { - String absolutePath = f.getAbsolutePath(); - String path = absolutePath.substring(basedirLength + 1); - File dst = new File(output, f.getName()); - if (withDescriptionFile && copyFiles) { - p.put(path, dst.getAbsolutePath()); - } else { - p.put(path, f.getAbsolutePath()); - } - getLog().info("collected file " + path); - if (!dryRun && copyFiles) { - try { - // copy the collected file - FileUtils.copyFile(f, dst); - } catch (IOException ex) { - throw new MojoExecutionException("could not copy file " + f, ex); - } - } - } - - if (description != null) { - try { - p.store(new FileOutputStream(description), "Generated by " + this.getClass()); - getLog().info("Save " + description); - } catch (IOException ex) { - throw new MojoExecutionException("could not save file " + description, ex); - } - } - } - - protected List<File> getFiles() { - - Pattern includePattern = includes == null || includes.trim().isEmpty() ? null : Pattern.compile(includes.trim()); - Pattern excludePattern = excludes == null || excludes.trim().isEmpty() ? null : Pattern.compile(excludes.trim()); - - List<File> result = new ArrayList<File>(); - - // attach the project mail file - - if (includeAttached) { - - if ("pom".equals(project.getPackaging())) { - addFile(project.getFile(), "adding artifact file : ", result, includePattern, excludePattern); - } else { - Artifact a = project.getArtifact(); - if (a != null) { - addFile(a.getFile(), "adding artifact file : ", result, includePattern, excludePattern); - } - } - } - File file; - - // attach extra files - - if (extraFiles != null && !extraFiles.trim().isEmpty()) { - - for (String path : extraFiles.split(",")) { - - file = new File(path); - addFile(file, "adding user file : ", result, includePattern, excludePattern); - - } - } - - // attach project attached files - - if (includeAttached && attachedArtifacts != null) { - - for (Object o : attachedArtifacts) { - - file = ((Artifact) o).getFile(); - addFile(file, "adding attached artifact file : ", result, includePattern, excludePattern); - } - } - - return result; - } - - protected MavenProject getExecutionRootProject() { - MavenProject root = project; - String executionRootDirectory = mavenSession.getExecutionRootDirectory(); - while (root != null) { - File basedir = root.getBasedir(); - getLog().debug("Current Folder:" + basedir); - boolean result = executionRootDirectory.equalsIgnoreCase(basedir.toString()); - if (result) { - break; - } - root = root.getParent(); - } - if (verbose) { - getLog().info("root project " + root); - } - return root; - } - - protected void addFile(File f, String msg, List<File> files, Pattern includePattern, Pattern excludePattern) { - if (f == null) { - return; - } - if (!f.exists()) { - getLog().warn("skip unexisting file " + f); - return; - } - if (excludePattern != null) { - if (excludePattern.matcher(f.getName()).matches()) { - // skip this file - if (verbose) { - getLog().info("skip " + f + " : in excludes " + excludes); - } - return; - } - } - if (includePattern != null) { - if (!includePattern.matcher(f.getName()).matches()) { - // skip this file - if (verbose) { - getLog().info("skip " + f + " : not in includes " + includes); - } - return; - } - } - if (verbose) { - getLog().info(msg + f); - } - files.add(f); - } -} - Deleted: jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/SendEmailMojo.java =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/SendEmailMojo.java 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/main/java/org/nuiton/jredmine/plugin/SendEmailMojo.java 2009-09-19 16:31:30 UTC (rev 186) @@ -1,458 +0,0 @@ -package org.nuiton.jredmine.plugin; - -import org.apache.maven.plugin.announcement.MailSender; -import org.nuiton.util.PluginHelper; - -import java.io.File; -import java.util.List; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Developer; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.announcement.mailsender.ProjectJavamailMailSender; -import org.apache.maven.project.MavenProject; -import org.apache.maven.settings.Server; -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.plugin.AbstractPlugin; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; - -/** - * Send a email. - * - * @goal send-email - * @requiresOnline true - * @requiresProject true - * - * @author tchemit - * @since 1.0.0 - */ -public class SendEmailMojo extends AbstractPlugin { - - /** - * @parameter expression="${session}" - * @required - * @readonly - */ - protected MavenSession mavenSession; - /** - * Dependance du projet. - * - * @parameter default-value="${project}" - * @required - * @readonly - * @since 1.0.0 - */ - protected MavenProject project; - /** - * Dependance du settings. - * - * @parameter default-value="${settings}" - * @required - * @readonly - * @since 1.0.0 - */ - protected Settings settings; - /** - * Un flag pour activer le mode verbeux. - * - * @parameter expression="${helper.verbose}" default-value="${maven.verbose}" - * @since 1.0.0 - */ - protected boolean verbose; - /** - * The Velocity template used to format the email announcement. - * - * @parameter expression="${helper.emailContentFile}" - * @required - * @since 1.0.0 - */ - private File emailContentFile; - /** - * The title of the email to send. - * - * @parameter expression="${helper.emailTitle}" - * @required - * @since 1.0.0 - */ - private String emailTitle; - /** - * Smtp Server. - * - * @parameter expression="${helper.smtpHost}" - * @required - */ - private String smtpHost; - /** - * Port. - * - * @parameter default-value="25" expression="${helper.smtpPort}" - * @required - */ - private int smtpPort; - /** - * The username used to send the email. - * - * @parameter expression="${helper.username}" - */ - private String username; - /** - * The password used to send the email. - * - * @parameter expression="${helper.password}" - */ - private String password; - /** - * Server id to use for authentication (must be defined in your setting - * and use the maven >= 2.1.0 password encryption mecanism). - * <p/> - * - * @parameter expression="${helper.serverId}" - * @since 1.0.0 - */ - protected String serverId; - /** - * If the email should be sent in SSL mode. - * - * @parameter default-value="false" expression="${helper.sslMode}" - */ - private 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}" - */ - private 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}" - */ - private MailSender mailSender; - /** - * Recipient email address. - * - * @parameter - * @required - */ - private List<String> toAddresses; - /** - * Possible senders. - * - * @parameter expression="${project.developers}" - * @required - * @readonly - */ - private List<Developer> from; - /** - * Mail content type to use. - * @parameter default-value="text/plain" - * @required - * @since 2.1 - */ - private String mailContentType; - /** - * The encoding used to read and write files. - * - * @parameter expression="${helper.encoding}" default-value="${project.build.sourceEncoding}" - * @since 1.0.0 - */ - protected String encoding; - /** - * A flag to skip the goal. - * - * @parameter expression="${helper.skipSendEmail}" default-value="false" - * @since 1.0.0 - */ - private boolean skipSendEmail; - /** - * A flag to test plugin but send nothing to redmine. - * - * @parameter expression="${dryRun}" default-value="false" - * @since 1.0.0 - */ - 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.0 - */ - private boolean runOnce; - /** - * password decypher - * - * @component roleHint="maven-redmine-plugin" - * @since 1.0.0 - */ - protected SecDispatcher sec; - 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; - } - - @Override - protected boolean ensurePackaging() { - // accept all project's packaging - return false; - } - - /////////////////////////////////////////////////////////////////////////// - /// AbstractPlugin - /////////////////////////////////////////////////////////////////////////// - protected boolean isGoalSkip() { - return skipSendEmail; - } - - @Override - protected boolean init() throws Exception { - - if (isGoalSkip()) { - return true; - } - - runOnceDone = false; - if (runOnce) { - // check - - if (!isExecutionRoot()) { - getLog().info("runOnce flag is on, will skip the goal"); - runOnceDone = true; - return true; - } - } - - if (!emailContentFile.exists()) { - // no file to publish... - getLog().warn("could not find the template " + emailContentFile); - getLog().warn("will skip send email..."); - return false; - } - - // check server (if used) - - Server server = null; - - if (serverId != null && !serverId.trim().isEmpty()) { - - server = settings.getServer(serverId); - - if (server == null) { - getLog().error("Could not find server with id '" + serverId + "', check your settings.xml file."); - return false; - } - } - - // check authentication configuration is stable - - boolean noUsername = username == null || username.trim().isEmpty(); - boolean noPassword = password == null || password.trim().isEmpty(); - - if (server != null && !noUsername) { - getLog().error("Authentication configuration is wrong :\ncan not use both 'serverId' and 'username' parameters, check your plugin configuration."); - return false; - } - - if (server != null && !noPassword) { - getLog().error("Authentication configuration is wrong :\ncan not use both 'serverId' and 'password' parameters, check your plugin configuration."); - return false; - } - - if ((noUsername && !noPassword) || (!noUsername && noPassword)) { - getLog().error("Authentication configuration is wrong :\nconfiguration is not complete, please fill parameter 'serverId' or 'username' and 'password'."); - return false; - } - - if (server != null) { - // obtain username and password from server - - username = server.getUsername(); - password = sec.decrypt(server.getPassword()); - } - - // check mail sender - - if (mailSender == null) { - - if (from == null || from.isEmpty()) { - 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) { - 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 (fromAddress == null || fromAddress.equals("")) { - getLog().warn("Invalid mail sender: name and email is mandatory (" + mailSender + ")."); - getLog().warn("will skip send email..."); - return false; - } - - return true; - } - - @Override - protected void doAction() throws Exception { - if (runOnce && runOnceDone) { - 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 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 == getExecutionRootProject(); - } - - protected MavenProject getExecutionRootProject() { - MavenProject root = project; - String executionRootDirectory = mavenSession.getExecutionRootDirectory(); - while (root != null) { - File dir = root.getBasedir(); - getLog().debug("Current Folder:" + dir); - boolean result = executionRootDirectory.equalsIgnoreCase(dir.toString()); - if (result) { - break; - } - root = root.getParent(); - } - if (verbose) { - getLog().info("root project " + root); - } - return root; - } -} Deleted: jredmine/trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/SendEmailMojoTest.java =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/SendEmailMojoTest.java 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/test/java/org/nuiton/jredmine/plugin/SendEmailMojoTest.java 2009-09-19 16:31:30 UTC (rev 186) @@ -1,63 +0,0 @@ -package org.nuiton.jredmine.plugin; - -import java.io.File; -import java.util.Arrays; -import junit.framework.Assert; -import org.apache.maven.plugin.announcement.MailSender; -import org.junit.Test; -import org.nuiton.plugin.AbstractMojoTest; - -/** - * @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); - - // copy redmine test server configuration - //TestHelper.copyConfiguration(TestHelper.getTestConfiguration(), mojo); - - - // 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")); - - canContinue = mojo.init(); - if (canContinue) { - if (mojo.isVerbose()) { - log.info("setup done for " + mojo.getProject().getFile().getName()); - } - } else { - log.warn("setup was not successfull, will skip this test [" + getClass() + "]"); - } - } - - @Test - public void sendEmail() throws Exception { - - Assert.assertNotNull(getMojo()); - getMojo().doAction(); - } - - @Test - public void skipSendEmail() throws Exception { - - Assert.assertNotNull(getMojo()); - getMojo().doAction(); - } -} Deleted: jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/mailContentFile.txt =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/mailContentFile.txt 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/mailContentFile.txt 2009-09-19 16:31:30 UTC (rev 186) @@ -1 +0,0 @@ -The content of the test email \ No newline at end of file Deleted: jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/sendEmail.xml =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/sendEmail.xml 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/sendEmail.xml 2009-09-19 16:31:30 UTC (rev 186) @@ -1,44 +0,0 @@ -<?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"> - - <groupId>org.nuiton.maven-redmine-plugin</groupId> - <artifactId>test-generate-changes</artifactId> - <version>0</version> - - <name>generate-changes</name> - - <build> - - <plugins> - <plugin> - <groupId>org.nuiton.jredmine</groupId> - <artifactId>maven-jredmine-plugin</artifactId> - <configuration> - <emailContentFile>target/test-classes/org/nuiton/jredmine/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 Deleted: jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/skipSendEmail.xml =================================================================== --- jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/skipSendEmail.xml 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/maven-jredmine-plugin/src/test/resources/org/nuiton/jredmine/plugin/SendEmailMojoTest/skipSendEmail.xml 2009-09-19 16:31:30 UTC (rev 186) @@ -1,34 +0,0 @@ -<?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"> - - <groupId>org.nuiton.maven-redmine-plugin</groupId> - <artifactId>test-generate-changes</artifactId> - <version>0</version> - - <name>generate-changes</name> - - <build> - - <plugins> - <plugin> - <groupId>org.nuiton.jredmine</groupId> - <artifactId>maven-jredmine-plugin</artifactId> - <configuration> - <emailContentFile>target/test-classes/org/nuiton/jredmine/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 Modified: jredmine/trunk/pom.xml =================================================================== --- jredmine/trunk/pom.xml 2009-09-19 16:31:10 UTC (rev 185) +++ jredmine/trunk/pom.xml 2009-09-19 16:31:30 UTC (rev 186) @@ -26,14 +26,14 @@ <scope>compile</scope> </dependency> - <!-- fix dependency pb in velocity (need at least version > 2.2) --> - <dependency> + <!-- fix dependency pb in velocity (need at least version > 2.2) --> + <!--<dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.4</version> - </dependency> + </dependency>--> - <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> + <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> @@ -72,18 +72,34 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changes-plugin</artifactId> <version>2.1</version> + <exclusions> + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-simple</artifactId> + </exclusion> + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-api</artifactId> + </exclusion> + + <exclusion> + <groupId>plexus</groupId> + <artifactId>plexus-mail-sender-javamail</artifactId> + </exclusion> + </exclusions> </dependency> + <!-- <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.0</version> - </dependency> - + </dependency>--> +<!-- <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>3.1</version> - </dependency> + </dependency>--> <dependency> <groupId>log4j</groupId>