KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > maven > MavenReporter


1 package hudson.maven;
2
3 import hudson.ExtensionPoint;
4 import hudson.model.Action;
5 import hudson.model.BuildListener;
6 import hudson.model.Describable;
7 import hudson.model.Project;
8 import hudson.tasks.BuildStep;
9 import org.apache.maven.project.MavenProject;
10
11 import java.io.IOException JavaDoc;
12 import java.io.Serializable JavaDoc;
13
14 /**
15  * Listens to the build execution of {@link MavenBuild},
16  * and normally records some information and exposes thoses
17  * in {@link MavenBuild} later.
18  *
19  * <p>
20  * TODO: talk about two nodes involved
21  * Because builds may happen on a remote slave node, {@link MavenReporter}
22  * implementation needs ...
23  *
24  * <p>
25  * This is the {@link MavenBuild} equivalent of {@link BuildStep}. Instances
26  * of {@link MavenReporter}s are persisted with {@link MavenModule}/{@link MavenModuleSet},
27  * possibly with configuration specific to that job.
28  *
29  *
30  * <h2>Callback Firing Sequence</h2>
31  * <p>
32  * The callback methods are invoked in the following order:
33  *
34  * <pre>
35  * SEQUENCE := preBuild MODULE* postBuild
36  * MODULE := enterModule MOJO+ leaveModule
37  * MOJO := preExecute postExecute
38  * </pre>
39  *
40  * <p>
41  * When an error happens, the call sequence could be terminated at any point
42  * and no further callback methods might not be invoked.
43  *
44  * @author Kohsuke Kawaguchi
45  * @see MavenReporters
46  */

47 public abstract class MavenReporter implements Describable<MavenReporter>, ExtensionPoint, Serializable JavaDoc {
48     /**
49      * Called before the actual maven2 execution begins.
50      *
51      * @param pom
52      * Represents the POM to be executed.
53      * @return
54      * true if the build can continue, false if there was an error
55      * and the build needs to be aborted.
56      * @throws InterruptedException
57      * If the build is interrupted by the user (in an attempt to abort the build.)
58      * Normally the {@link MavenReporter} implementations may simply forward the exception
59      * it got from its lower-level functions.
60      * @throws IOException
61      * If the implementation wants to abort the processing when an {@link IOException}
62      * happens, it can simply propagate the exception to the caller. This will cause
63      * the build to fail, with the default error message.
64      * Implementations are encouraged to catch {@link IOException} on its own to
65      * provide a better error message, if it can do so, so that users have better
66      * understanding on why it failed.
67      */

68     public boolean preBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
69         return true;
70     }
71
72     /**
73      * Called when the build enters a next {@link MavenProject}.
74      *
75      * <p>
76      * When the current build is a multi-module reactor build, every time the build
77      * moves on to the next module, this method will be invoked.
78      *
79      * <p>
80      * Note that as of Maven 2.0.4, Maven does not perform any smart optimization
81      * on the order of goal executions. Therefore, the same module might be entered more than
82      * once during the build.
83      *
84      * @return
85      * See {@link #preBuild}
86      * @throws InterruptedException
87      * See {@link #preBuild}
88      * @throws IOException
89      * See {@link #preBuild}
90      */

91     public boolean enterModule(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
92         return true;
93     }
94
95     /**
96      * Called when the build leaves the current {@link MavenProject}.
97      *
98      * @see #enterModule
99      */

100     public boolean leaveModule(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
101         return true;
102     }
103
104     /**
105      * Called before execution of a single mojo.
106      *
107      * @return
108      * See {@link #preBuild}
109      * @throws InterruptedException
110      * See {@link #preBuild}
111      * @throws IOException
112      * See {@link #preBuild}
113      */

114     public boolean preExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
115         return true;
116     }
117
118     /**
119      * Called after execution of a single mojo.
120      * <p>
121      * See {@link #preExecute} for the contract.
122      */

123     public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
124         return true;
125     }
126
127     /**
128      * Called after the actual maven2 execution completed.
129      *
130      * @return
131      * See {@link #preBuild}
132      * @throws InterruptedException
133      * See {@link #preBuild}
134      * @throws IOException
135      * See {@link #preBuild}
136      */

137     public boolean postBuild(MavenBuildProxy build, MavenProject pom, BuildListener listener) throws InterruptedException JavaDoc, IOException JavaDoc {
138         return true;
139     }
140
141     /**
142      * Equivalent of {@link BuildStep#getProjectAction(Project)}
143      * for {@link MavenReporter}.
144      */

145     public Action getProjectAction(MavenModule module) {
146         return null;
147     }
148
149     public abstract MavenReporterDescriptor getDescriptor();
150 }
151
Popular Tags