Example usage for org.apache.maven.execution ExecutionEvent getException

List of usage examples for org.apache.maven.execution ExecutionEvent getException

Introduction

In this page you can find the example usage for org.apache.maven.execution ExecutionEvent getException.

Prototype

Exception getException();

Source Link

Document

Gets the exception that caused the event (if any).

Usage

From source file:org.jenkinsci.plugins.pipeline.maven.eventspy.handler.AbstractExecutionHandler.java

License:Open Source License

@Override
public boolean _handle(@Nonnull ExecutionEvent executionEvent) {
    List<String> configurationParameters = getConfigurationParametersToReport(executionEvent);

    Xpp3Dom root = new Xpp3Dom("ExecutionEvent");
    root.setAttribute("class", executionEvent.getClass().getName());
    root.setAttribute("type", executionEvent.getType().name());

    root.addChild(newElement("project", executionEvent.getProject()));

    MojoExecution execution = executionEvent.getMojoExecution();

    if (execution == null) {
        root.addChild(new Xpp3Dom("no-execution-found"));
    } else {/*ww  w. j  a  v  a2s. c  o m*/
        Xpp3Dom plugin = new Xpp3Dom("plugin");
        root.addChild(plugin);

        plugin.setAttribute("groupId", execution.getGroupId());
        plugin.setAttribute("artifactId", execution.getArtifactId());
        plugin.setAttribute("goal", execution.getGoal());
        plugin.setAttribute("version", execution.getVersion());
        if (execution.getExecutionId() != null) {
            // See JENKINS-47508, caused by plugin being declared and invoked by the <reports> section
            plugin.setAttribute("executionId", execution.getExecutionId());
        }
        if (execution.getLifecyclePhase() != null) {
            // protect against null lifecyclePhase. cause is NOT clear
            plugin.setAttribute("lifecyclePhase", execution.getLifecyclePhase());
        }

        for (String configurationParameter : configurationParameters) {
            Xpp3Dom element = fullClone(configurationParameter,
                    execution.getConfiguration().getChild(configurationParameter));
            if (element != null) {
                plugin.addChild(element);
            }
        }
    }

    addDetails(executionEvent, root);

    if (executionEvent.getException() != null) {
        root.addChild(newElement("exception", executionEvent.getException()));
    }

    reporter.print(root);

    return true;
}