Example usage for org.apache.maven.execution MavenExecutionRequest getBaseDirectory

List of usage examples for org.apache.maven.execution MavenExecutionRequest getBaseDirectory

Introduction

In this page you can find the example usage for org.apache.maven.execution MavenExecutionRequest getBaseDirectory.

Prototype

String getBaseDirectory();

Source Link

Usage

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   ww w .j  a  v a 2  s .com

    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:org.jenkinsci.plugins.pipeline.maven.eventspy.handler.MavenExecutionRequestHandler.java

License:Open Source License

@Override
protected boolean _handle(MavenExecutionRequest request) {
    Xpp3Dom root = new Xpp3Dom("MavenExecutionRequest");
    root.setAttribute("class", request.getClass().getName());
    root.addChild(newElement("pom", request.getPom()));
    root.addChild(newElement("globalSettingsFile", request.getGlobalSettingsFile()));
    root.addChild(newElement("userSettingsFile", request.getUserSettingsFile()));
    root.addChild(newElement("baseDirectory", request.getBaseDirectory()));

    reporter.print(root);/*from  ww  w  .java 2  s. c  o  m*/
    return true;
}