KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > maven > reporters > MavenMailer


1 package hudson.maven.reporters;
2
3 import hudson.maven.MavenReporter;
4 import hudson.maven.MavenReporterDescriptor;
5 import hudson.maven.MavenBuildProxy;
6 import hudson.maven.MavenBuild;
7 import hudson.maven.MavenBuildProxy.BuildCallable;
8 import hudson.tasks.Mailer;
9 import hudson.tasks.MailSender;
10 import hudson.model.BuildListener;
11 import org.kohsuke.stapler.StaplerRequest;
12 import org.apache.maven.project.MavenProject;
13
14 import java.io.IOException JavaDoc;
15
16 /**
17  * @author Kohsuke Kawaguchi
18  */

19 public class MavenMailer extends MavenReporter {
20     /**
21      * @see Mailer
22      */

23     public String JavaDoc recipients;
24     public boolean dontNotifyEveryUnstableBuild;
25     public boolean sendToIndividuals;
26
27
28     public boolean postBuild(MavenBuildProxy build, MavenProject pom, final BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
29         build.execute(new BuildCallable<Void JavaDoc,IOException JavaDoc>() {
30             public Void JavaDoc call(MavenBuild build) throws IOException JavaDoc, InterruptedException JavaDoc {
31                 new MailSender(recipients,dontNotifyEveryUnstableBuild,sendToIndividuals).execute(build,listener);
32                 return null;
33             }
34         });
35         return true;
36     }
37
38     public DescriptorImpl getDescriptor() {
39         return DescriptorImpl.DESCRIPTOR;
40     }
41
42     public static final class DescriptorImpl extends MavenReporterDescriptor {
43         public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
44
45         private DescriptorImpl() {
46             super(MavenMailer.class);
47         }
48
49         public String JavaDoc getDisplayName() {
50             return "E-mail Notification";
51         }
52
53         public String JavaDoc getHelpFile() {
54             return "/help/project-config/mailer.html";
55         }
56
57         // reuse the config from the mailer.
58
@Override JavaDoc
59         public String JavaDoc getConfigPage() {
60             return getViewPage(Mailer.class,"config.jelly");
61         }
62
63         public MavenMailer newInstance(StaplerRequest req) {
64             MavenMailer m = new MavenMailer();
65             req.bindParameters(m,"mailer_");
66             return m;
67         }
68     }
69
70     private static final long serialVersionUID = 1L;
71 }
72
Popular Tags