}
@Override
public void onEvent(Object event) throws Exception {
if (event instanceof ExecutionEvent) {
ExecutionEvent executionEvent = (ExecutionEvent) event;
if (executionEvent.getType() == ExecutionEvent.Type.SessionStarted) {
//
//
//
sessionProfile = new SessionProfile();
} else if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) {
//
//
//
sessionProfile.stop();
if (System.getProperty(TESLA_PROFILE) != null) {
renderer.render(sessionProfile);
}
} else if (executionEvent.getType() == ExecutionEvent.Type.ProjectStarted) {
//
// We need to collect the mojoExecutions within each project
//
projectProfile = new ProjectProfile(executionEvent.getProject());
} else if (executionEvent.getType() == ExecutionEvent.Type.ProjectSucceeded || executionEvent.getType() == ExecutionEvent.Type.ProjectFailed) {
//
//
//
projectProfile.stop();
sessionProfile.addProjectProfile(projectProfile);
} else if (executionEvent.getType() == ExecutionEvent.Type.MojoStarted) {
String phase = executionEvent.getMojoExecution().getLifecyclePhase();
//
// Create a new phase profile if one doesn't exist or the phase has changed.
//
if (phaseProfile == null) {
phaseProfile = new PhaseProfile(phase);
} else if (!phaseProfile.getPhase().equals(phase)) {
phaseProfile.stop();
projectProfile.addPhaseProfile(phaseProfile);
phaseProfile = new PhaseProfile(phase);
}
mojoProfile = new MojoProfile(executionEvent.getMojoExecution());
} else if (executionEvent.getType() == ExecutionEvent.Type.MojoSucceeded || executionEvent.getType() == ExecutionEvent.Type.MojoFailed) {
//
//
//
mojoProfile.stop();
phaseProfile.addMojoProfile(mojoProfile);