Class MavenReporter
- All Implemented Interfaces:
ExtensionPoint
,MavenProjectActionBuilder
,Describable<MavenReporter>
,Serializable
- Direct Known Subclasses:
AbstractMavenJavadocArchiver
,BuildInfoRecorder
,MavenArtifactArchiver
,MavenFingerprinter
,MavenMailer
,MavenSiteArchiver
,ReportCollector
,TestFailureDetector
MavenBuild
,
and normally records some information and exposes thoses
in MavenBuild
later.
MavenReporter
is first instanciated on the controller.
Then during the build, it is serialized and sent over into
the maven process by serialization. Reporters will then receive
event callbacks as mojo execution progresses. Those event callbacks
are the ones that take MavenBuildProxy
.
Once the maven build completes normally or abnormally, the reporters
will be sent back to the controller by serialization again, then
have its end(MavenBuild, Launcher, BuildListener)
method invoked.
This is a good opportunity to perform the post-build action.
This is the MavenBuild
equivalent of BuildStep
. Instances
of MavenReporter
s are persisted with MavenModule
/MavenModuleSet
,
possibly with configuration specific to that job.
Callback Firing Sequence
The callback methods are invoked in the following order:
SEQUENCE := preBuild MODULE* postBuild end MODULE := enterModule MOJO+ leaveModule MOJO := preExecute postExecute
When an error happens, the call sequence could be terminated at any point and no further callback methods may be invoked.
Action
MavenReporter
can contribute
Action
to MavenBuild
so that the report can be displayed
in the web UI.
Such action can also implement AggregatableAction
if it further
wishes to contribute a separate action to MavenModuleSetBuild
.
This mechanism is usually used to provide aggregated report for all the
module builds.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
end
(MavenBuild build, Launcher launcher, BuildListener listener) Called after the maven execution finished and the result is determined.boolean
enterModule
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) Called when the build enters a nextMavenProject
.getAggregatedProjectAction
(MavenModuleSet project) Works likegetProjectAction(MavenModule)
but works atMavenModuleSet
level.getProjectAction
(MavenModule module) Deprecated.Collection<? extends Action>
getProjectActions
(MavenModule module) Equivalent ofBuildStep.getProjectActions(AbstractProject)
forMavenReporter
.boolean
leaveModule
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) Called when the build leaves the currentMavenProject
.boolean
postBuild
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) Called after a build of one maven2 module is completed.boolean
postExecute
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) Called after execution of a single mojo.boolean
preBuild
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) Called before the actual maven2 execution begins.boolean
preExecute
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MojoInfo mojo, BuildListener listener) Called before execution of a single mojo.boolean
reportGenerated
(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MavenReportInfo report, BuildListener listener) Called after aMavenReport
is successfully generated.
-
Constructor Details
-
MavenReporter
public MavenReporter()
-
-
Method Details
-
preBuild
public boolean preBuild(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) throws InterruptedException, IOException Called before the actual maven2 execution begins.- Parameters:
pom
- Represents the POM to be executed.- Returns:
- true if the build can continue, false if there was an error and the build needs to be aborted.
- Throws:
InterruptedException
- If the build is interrupted by the user (in an attempt to abort the build.) Normally theMavenReporter
implementations may simply forward the exception it got from its lower-level functions.IOException
- If the implementation wants to abort the processing when anIOException
happens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catchIOException
on its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.
-
enterModule
public boolean enterModule(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) throws InterruptedException, IOException Called when the build enters a nextMavenProject
.When the current build is a multi-module reactor build, every time the build moves on to the next module, this method will be invoked.
Note that as of Maven 2.0.4, Maven does not perform any smart optimization on the order of goal executions. Therefore, the same module might be entered more than once during the build.
- Returns:
- See
preBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
- Throws:
InterruptedException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
IOException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
-
leaveModule
public boolean leaveModule(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) throws InterruptedException, IOException Called when the build leaves the currentMavenProject
. -
preExecute
public boolean preExecute(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MojoInfo mojo, BuildListener listener) throws InterruptedException, IOException Called before execution of a single mojo.When this method is invoked,
MojoInfo.mojo
is fully injected with its configuration values.- Returns:
- See
preBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
- Throws:
InterruptedException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
IOException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
-
postExecute
public boolean postExecute(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException Called after execution of a single mojo.See
preExecute(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.maven.MojoInfo, hudson.model.BuildListener)
for the contract.- Parameters:
error
- If mojo execution failed withMojoFailureException
orMojoExecutionException
, this method is still invoked with those error objects. If mojo executed successfully, this parameter is null.- Throws:
InterruptedException
IOException
-
postBuild
public boolean postBuild(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, BuildListener listener) throws InterruptedException, IOException Called after a build of one maven2 module is completed.Note that at this point the build result is still not determined.
- Returns:
- See
preBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
- Throws:
InterruptedException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
IOException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
-
end
public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException Called after the maven execution finished and the result is determined.This method fires after
postBuild(MavenBuildProxy, MavenProject, BuildListener)
. Works likeBuildStepCompatibilityLayer.perform(Build, Launcher, BuildListener)
.- Throws:
InterruptedException
IOException
-
reportGenerated
public boolean reportGenerated(MavenBuildProxy build, org.apache.maven.project.MavenProject pom, MavenReportInfo report, BuildListener listener) throws InterruptedException, IOException Called after aMavenReport
is successfully generated.MavenReport
is an execution unit inside the Maven site plugin mojos, such assite:generate
. These are what's configured through<reporting>
tag inside POM, although there's normally moreMavenReport
s than what's specified explicitly, due to defaulting and inheritance and all the other Maven processing.This provides an opportunity for plugins to auto-perform some action when a certain reporting is generated.
This method is invoked during the execution of site mojos, between its
preExecute(MavenBuildProxy, MavenProject, MojoInfo, BuildListener)
andpostExecute(MavenBuildProxy, MavenProject, MojoInfo, BuildListener, Throwable)
- Returns:
- See
preBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
- Throws:
InterruptedException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
IOException
- SeepreBuild(hudson.maven.MavenBuildProxy, org.apache.maven.project.MavenProject, hudson.model.BuildListener)
- Since:
- 1.237
-
getProjectAction
Deprecated.as of 1.341 UsegetProjectActions(MavenModule)
instead.Equivalent ofBuildStep.getProjectAction(AbstractProject)
forMavenReporter
.Registers a transient action to
MavenModule
when it's rendered. This is useful if you'd like to display an action at the module level.Since this contributes a transient action, the returned
Action
will not be serialized.For this method to be invoked, your
MavenReporter
has to invokeMavenBuildProxy.registerAsProjectAction(MavenReporter)
during the build.- Returns:
- null not to contribute an action, which is the default.
-
getProjectActions
Equivalent ofBuildStep.getProjectActions(AbstractProject)
forMavenReporter
.Registers a transient action to
MavenModule
when it's rendered. This is useful if you'd like to display an action at the module level.Since this contributes a transient action, the returned
Action
will not be serialized.For this method to be invoked, your
MavenReporter
has to invokeMavenBuildProxy.registerAsProjectAction(MavenReporter)
during the build.- Specified by:
getProjectActions
in interfaceMavenProjectActionBuilder
- Returns:
- can be empty but never null.
- Since:
- 1.341
-
getAggregatedProjectAction
Works likegetProjectAction(MavenModule)
but works atMavenModuleSet
level.For this method to be invoked, your
MavenReporter
has to invokeMavenBuildProxy.registerAsAggregatedProjectAction(MavenReporter)
during the build.- Returns:
- null not to contribute an action, which is the default.
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<MavenReporter>
-
getProjectActions(MavenModule)
instead.