Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!getProject().isExecutionRoot()) {
- return ;
- }
- /**
- * The projects in the reactor.
- *
- * @parameter expression="${reactorProjects}"
- * @readonly
- */
- private List reactorProjects;
- public void execute() throws MojoExecutionException {
- // only execute this mojo once, on the very last project in the reactor
- final int size = reactorProjects.size();
- MavenProject lastProject = (MavenProject) reactorProjects.get(size - 1);
- if (lastProject != getProject()) {
- return;
- }
- // do work
- ...
- }
- boolean result = mavenSession.getExecutionRootDirectory().equalsIgnoreCase(basedir.toString());
- /**
- * 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()
- {
- ...
- }
Add Comment
Please, Sign In to add comment