List of usage examples for org.apache.maven.execution ExecutionEvent getType
Type getType();
From source file:co.leantechniques.maven.Project.java
License:Apache License
private boolean isMojoFinished(ExecutionEvent event) { return event.getType() == ExecutionEvent.Type.MojoSucceeded; }
From source file:com.ccoe.build.profiler.lifecycle.MavenLifecycleProfiler.java
License:Apache License
@Override public void onEvent(Object event) throws Exception { if (event instanceof SettingsBuildingRequest) { SettingsBuildingRequest settingBuildingRequest = (SettingsBuildingRequest) event; userSettingFile = settingBuildingRequest.getUserSettingsFile(); globalSettingFile = settingBuildingRequest.getGlobalSettingsFile(); }//from w ww .j a v a2 s . c o m if (event instanceof MavenExecutionRequest) { MavenExecutionRequest mer = (MavenExecutionRequest) event; debug = (mer.getLoggingLevel() == MavenExecutionRequest.LOGGING_LEVEL_DEBUG); context.getData().put("baseAdd", mer.getBaseDirectory()); } if (event instanceof ExecutionEvent) { ExecutionEvent executionEvent = (ExecutionEvent) event; if (executionEvent.getType() == ExecutionEvent.Type.ProjectDiscoveryStarted) { discoveryProfile = new DiscoveryProfile(context, executionEvent, userSettingFile, globalSettingFile, debug); } else if (executionEvent.getType() == ExecutionEvent.Type.SessionStarted) { sessionProfile = new SessionProfile(context, executionEvent, debug); } else if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) { projectProfile.addPhaseProfile(phaseProfile); //if can accelerate,we will not generate the dependency file sessionProfile.stop(); discoveryProfile.stop(); OutputRenderer renderer = new OutputRenderer(sessionProfile, discoveryProfile); renderer.renderToScreen(); // renderer.renderToJSON(); } else if (executionEvent.getType() == ExecutionEvent.Type.ProjectStarted) { projectProfile = new ProjectProfile(context, executionEvent.getProject(), executionEvent); } else if (executionEvent.getType() == ExecutionEvent.Type.ProjectSucceeded || executionEvent.getType() == ExecutionEvent.Type.ProjectFailed) { if (phaseProfile != null) phaseProfile.stop(); projectProfile.stop(); sessionProfile.addProjectProfile(projectProfile); } else if (executionEvent.getType() == ExecutionEvent.Type.MojoStarted) { String phase = executionEvent.getMojoExecution().getLifecyclePhase(); if (phaseProfile == null) { phaseProfile = new PhaseProfile(context, phase, executionEvent); } else if (phase == null) { phaseProfile.stop(); projectProfile.addPhaseProfile(phaseProfile); phaseProfile = new PhaseProfile(context, "default", executionEvent); } else if (!phase.equals(phaseProfile.getPhase())) { phaseProfile.stop(); projectProfile.addPhaseProfile(phaseProfile); phaseProfile = new PhaseProfile(context, phase, executionEvent); } mojoProfile = new MojoProfile(context, executionEvent.getMojoExecution(), executionEvent); } else if (executionEvent.getType() == ExecutionEvent.Type.MojoSucceeded || executionEvent.getType() == ExecutionEvent.Type.MojoFailed) { mojoProfile.stop(); phaseProfile.addMojoProfile(mojoProfile); } } }
From source file:com.paulhammant.buildradiatorextension.BuildRadiatorEventSpy.java
License:Open Source License
@Override public void onEvent(Object event) throws Exception { try {// w w w . j a v a2 s . c om try { if (event instanceof ExecutionEvent) { ExecutionEvent executionEvent = (ExecutionEvent) event; MavenProject project = executionEvent.getProject(); String lifecyclePhase = executionEvent.getMojoExecution().getLifecyclePhase(); String phase = lifecyclePhase.substring(lifecyclePhase.lastIndexOf(':') + 1); String execution = executionEvent.getMojoExecution().getExecutionId(); String currentArtifactId = project.getArtifactId(); if (!projectPropertiesDone) { this.buildRadiatorInterop.projectProperties(project.getProperties(), project.getArtifactId()); projectPropertiesDone = true; } String status = executionEvent.getType().toString(); if (executionEvent.getType() == ExecutionEvent.Type.MojoStarted) { status = "started"; } else if (executionEvent.getType() == ExecutionEvent.Type.MojoFailed) { status = "failed"; } else if (executionEvent.getType() == ExecutionEvent.Type.MojoSucceeded) { status = "passed"; } this.buildRadiatorInterop.executionEvent(phase, execution, currentArtifactId, status); } if (event instanceof DefaultMavenExecutionResult) { DefaultMavenExecutionResult dmer = (DefaultMavenExecutionResult) event; this.buildRadiatorInterop.executionResult( dmer.getBuildSummary(dmer.getProject()) instanceof BuildSuccess, dmer.getBuildSummary(dmer.getProject()) instanceof BuildFailure); } } catch (NullPointerException e) { // do nothing } } catch (Throwable e) { e.printStackTrace(); } }
From source file:com.soebes.maven.extensions.BuildTimeProfiler.java
License:Apache License
private void executionEventHandler(ExecutionEvent executionEvent) { Type type = executionEvent.getType(); switch (type) { case ProjectDiscoveryStarted: // Start reading the pom files.. discoveryTimer.discoveryStart(); break;// w w w .j av a2s . c o m case SessionStarted: // Reading of pom files done and structure now there. discoveryTimer.discoveryStop(); // executionEvent.getSession().getProjectDependencyGraph().getSortedProjects(); sessionTimer.sessionStart(); break; case SessionEnded: // Everything is done. sessionTimer.sessionStop(); break; case ForkStarted: forkTimer.start(); break; case ForkFailed: case ForkSucceeded: forkTimer.stop(); break; case ForkedProjectStarted: forkProject.projectStart(executionEvent); break; case ForkedProjectFailed: case ForkedProjectSucceeded: forkProject.projectStop(executionEvent); break; case MojoStarted: String phase = executionEvent.getMojoExecution().getLifecyclePhase(); collectAllLifeCylcePhases(phase); // Key: phase, project, mojo mojoTimer.mojoStart(executionEvent); break; case MojoFailed: case MojoSucceeded: case MojoSkipped: mojoTimer.mojoStop(executionEvent); break; case ProjectStarted: projectTimer.projectStart(executionEvent); break; case ProjectFailed: case ProjectSucceeded: case ProjectSkipped: projectTimer.projectStop(executionEvent); break; default: LOGGER.error("MBTP: executionEventHandler: {}", type); break; } }
From source file:com.soebes.maven.extensions.deploy.archiver.DeployArchiver.java
License:Apache License
private void executionEventHandler(ExecutionEvent executionEvent) { Type type = executionEvent.getType(); switch (type) { case ProjectDiscoveryStarted: break;//w w w . j av a 2s. co m case SessionStarted: sessionStarted(executionEvent); break; case SessionEnded: if (this.failure) { LOGGER.warn("The Deploye Archiver Extension will not be called based on previous errors."); } else { sessionEnded(executionEvent); } break; case ForkFailed: case ForkedProjectFailed: case MojoFailed: case ProjectFailed: // TODO: Can we find out more about the cause of failure? LOGGER.debug("Some failure has occured."); this.failure = true; break; case ForkStarted: case ForkSucceeded: case ForkedProjectStarted: case ForkedProjectSucceeded: case MojoStarted: case MojoSucceeded: case MojoSkipped: case ProjectStarted: case ProjectSucceeded: case ProjectSkipped: break; default: LOGGER.error("executionEventHandler: {}", type); break; } }
From source file:io.tesla.lifecycle.profiler.LifecycleProfiler.java
License:Open Source License
@Override public void onEvent(Object event) throws Exception { if (event instanceof ExecutionEvent) { ExecutionEvent executionEvent = (ExecutionEvent) event; if (executionEvent.getType() == ExecutionEvent.Type.SessionStarted) { ///*from w ww .java2s . co m*/ // // sessionProfile = new SessionProfile(); } else if (executionEvent.getType() == ExecutionEvent.Type.SessionEnded) { // // // sessionProfile.stop(); if (System.getProperty(TESLA_PROFILE) != null) { renderer.render(sessionProfile, System.getProperty(TESLA_PROFILE)); } } 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) { if (phaseProfile != null) { phaseProfile.stop(); projectProfile.addPhaseProfile(phaseProfile); } // // if (phaseProfile != null) { phaseProfile.stop(); projectProfile.addPhaseProfile(phaseProfile); phaseProfile = null; } 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); } } }
From source file:org.commonjava.maven.ext.manip.ManipulatingEventSpy.java
License:Open Source License
@Override public void onEvent(final Object event) throws Exception { boolean required = false; try {//from w w w . jav a2 s . co m if (event instanceof ExecutionEvent) { final ExecutionEvent ee = (ExecutionEvent) event; required = Boolean.parseBoolean( ee.getSession().getRequest().getUserProperties().getProperty(REQUIRE_EXTENSION, "false")); final ExecutionEvent.Type type = ee.getType(); if (type == Type.ProjectDiscoveryStarted) { if (ee.getSession() != null) { if (ee.getSession().getRequest().getLoggingLevel() == 0) { final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory .getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); root.setLevel(Level.DEBUG); } manipulationManager.init(ee.getSession(), session); } if (!session.isEnabled()) { logger.info("Manipulation engine disabled{}", (session.getExecutionRoot() == null ? ". No project found." : " via command-line option")); super.onEvent(event); return; } else if (new File(session.getExecutionRoot().getParentFile(), MARKER_FILE).exists()) { logger.info("Skipping manipulation as previous execution found."); super.onEvent(event); return; } manipulationManager.scan(session.getExecutionRoot(), session); final List<Project> projects = session.getProjects(); for (final Project project : projects) { logger.debug("Got " + project + " (POM: " + project.getPom() + ")"); } // Create a marker file if we made some changes to prevent duplicate runs. if (!manipulationManager.applyManipulations(projects, session).isEmpty()) { try { new File(session.getExecutionRoot().getParentFile(), MARKER_PATH).mkdirs(); new File(session.getExecutionRoot().getParentFile(), MARKER_FILE).createNewFile(); } catch (IOException e) { throw new ManipulationException("Marker file creation failed", e); } } } } } catch (final ManipulationException e) { logger.error("Extension failure", e); if (required) { throw e; } else { session.setError(e); } } super.onEvent(event); }
From source file:org.debian.dependency.ProjectArtifactSpy.java
License:Apache License
@Override public void onEvent(final Object event) { if (!(event instanceof ExecutionEvent)) { return;// w ww . j a va2s. c om } ExecutionEvent execEvent = (ExecutionEvent) event; if (!Type.ProjectSucceeded.equals(execEvent.getType()) && !Type.ForkedProjectSucceeded.equals(execEvent.getType())) { return; } MavenProject project = execEvent.getProject(); Artifact pomArtifact = repoSystem.createProjectArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion()); pomArtifact.setFile(project.getFile()); // the first project should always be the top-level project if (outputFile == null) { outputFile = new File(project.getBuild().getDirectory(), ServicePackage.PROJECT_ARTIFACT_REPORT_NAME); } recordArtifact(pomArtifact); recordArtifact(project.getArtifact()); for (Artifact artifact : project.getAttachedArtifacts()) { recordArtifact(artifact); } }
From source file:org.hudsonci.maven.eventspy_30.handler.ExecutionEventHandler.java
License:Open Source License
public void handle(final ExecutionEvent event) throws Exception { Type type = event.getType(); log.debug("Execution event type: {}", type); recordSessionStarted(event);/*from w w w .j a v a 2 s.c om*/ recordProjectStarted(event); recordMojoStarted(event); recordProjectFinished(event); // TODO: could probably handle SessionEnded instead of MavenExecutionResult // in MavenExecutionResultHandler }
From source file:org.hudsonci.maven.eventspy_30.handler.ExecutionEventHandler.java
License:Open Source License
private void recordSessionStarted(final ExecutionEvent event) { if (SessionStarted.equals(event.getType())) { List<MavenProject> projects = event.getSession().getProjects(); log.debug("Recording MavenProjects"); getBuildRecorder().recordSessionStarted(projects); ProfileLogger.log(event); // TODO: is this needed anymore? }/*from w w w . j av a 2 s. co m*/ }