I am wondering how would one get the status of a build (ERROR/SUCCESS) from a maven plugin ?
+1
A:
You can't easily do that. Maven plugins fail by throwing a org.apache.maven.plugin.MojoExecutionException
or a org.apache.maven.plugin.MojoFailureException
, and you don't have a hook to listen to these exceptions. Certainly not with a plugin, because your plugin wouldn't be executed after a failure.
There might be the possibility to use custom versions of
org.apache.maven.lifecycle.DefaultLifecycleExecutor
or
org.apache.maven.DefaultMaven
that you can inject via plexus and wrap plugin execution in try / catch to perfom your logic afterwards, but this is very heavy stuff.
Read here about accessing the plexus container
seanizer
2010-06-28 09:02:17