I have a MOJO I would like executed once, and once only after the test phase of the last project in the reactor to run.
Using:
if (!getProject().isExecut
Check out maven-monitor API
You can add an EventMonitor to the dispatcher, and then trap the END of the 'reactor-execute' event: this is dispatched after everything is completed, i.e. even after you see the BUILD SUCCESSFUL/FAILED output.
Here's how I used it recently to print a summary right at the end:
/**
* The Maven Project Object
*
* @parameter expression="${project}"
* @required
* @readonly
*/
protected MavenProject project;
/**
* The Maven Session.
*
* @parameter expression="${session}"
* @required
* @readonly
*/
protected MavenSession session;
...
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
//Register the event handler right at the start only
if (project.isExecutionRoot())
registerEventMonitor();
...
}
/**
* Register an {@link EventMonitor} with Maven so that we can respond to certain lifecycle events
*/
protected void registerEventMonitor()
{
session.getEventDispatcher().addEventMonitor(
new EventMonitor() {
@Override
public void endEvent(String eventName, String target, long arg2) {
if (eventName.equals("reactor-execute"))
printSummary();
}
@Override
public void startEvent(String eventName, String target, long arg2) {}
@Override
public void errorEvent(String eventName, String target, long arg2, Throwable arg3) {}
}
);
}
/**
* Print summary at end
*/
protected void printSummary()
{
...
}