4

I am wondering how would one get the status of a build (ERROR/SUCCESS) from a Maven plugin ?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Rich
  • 41
  • 2

1 Answers1

4

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

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588