Rich
Rich

Reputation: 41

Detect Maven build status (SUCCESS/ERROR) from a Maven plugin

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

Upvotes: 4

Views: 1187

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299218

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

Upvotes: 4

Related Questions