Search in sources :

Example 1 with BuildActionResult

use of org.gradle.tooling.internal.provider.BuildActionResult in project gradle by gradle.

the class ClientProvidedBuildActionRunner method buildResult.

@SuppressWarnings("deprecation")
private BuildActionResult buildResult(Object clientAction, GradleInternal gradle) {
    forceFullConfiguration(gradle);
    DefaultBuildController internalBuildController = new DefaultBuildController(gradle);
    Object model = null;
    Throwable failure = null;
    try {
        if (clientAction instanceof InternalBuildActionVersion2<?>) {
            model = ((InternalBuildActionVersion2) clientAction).execute(internalBuildController);
        } else {
            model = ((org.gradle.tooling.internal.protocol.InternalBuildAction) clientAction).execute(internalBuildController);
        }
    } catch (BuildCancelledException e) {
        failure = new InternalBuildCancelledException(e);
    } catch (RuntimeException e) {
        failure = new InternalBuildActionFailureException(e);
    }
    PayloadSerializer payloadSerializer = getPayloadSerializer(gradle);
    if (failure != null) {
        return new BuildActionResult(null, payloadSerializer.serialize(failure));
    } else {
        return new BuildActionResult(payloadSerializer.serialize(model), null);
    }
}
Also used : PayloadSerializer(org.gradle.tooling.internal.provider.serialization.PayloadSerializer) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException) InternalBuildActionFailureException(org.gradle.tooling.internal.protocol.InternalBuildActionFailureException) BuildActionResult(org.gradle.tooling.internal.provider.BuildActionResult) InternalBuildActionVersion2(org.gradle.tooling.internal.protocol.InternalBuildActionVersion2) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException) BuildCancelledException(org.gradle.api.BuildCancelledException)

Example 2 with BuildActionResult

use of org.gradle.tooling.internal.provider.BuildActionResult in project gradle by gradle.

the class TestExecutionRequestActionRunner method run.

@Override
public void run(BuildAction action, BuildController buildController) {
    if (!(action instanceof TestExecutionRequestAction)) {
        return;
    }
    GradleInternal gradle = buildController.getGradle();
    try {
        TestExecutionRequestAction testExecutionRequestAction = (TestExecutionRequestAction) action;
        TestExecutionResultEvaluator testExecutionResultEvaluator = new TestExecutionResultEvaluator(testExecutionRequestAction);
        buildOperationListenerManager.addListener(testExecutionResultEvaluator);
        try {
            doRun(testExecutionRequestAction, buildController);
        } finally {
            buildOperationListenerManager.removeListener(testExecutionResultEvaluator);
        }
        testExecutionResultEvaluator.evaluate();
    } catch (RuntimeException rex) {
        Throwable throwable = findRootCause(rex);
        if (throwable instanceof TestExecutionException) {
            // Tunnel the failure through the reporting
            throw new ReportedException(new InternalTestExecutionException("Error while running test(s)", throwable));
        } else {
            throw rex;
        }
    }
    PayloadSerializer payloadSerializer = gradle.getServices().get(PayloadSerializer.class);
    buildController.setResult(new BuildActionResult(payloadSerializer.serialize(null), null));
}
Also used : TestExecutionRequestAction(org.gradle.tooling.internal.provider.TestExecutionRequestAction) GradleInternal(org.gradle.api.internal.GradleInternal) PayloadSerializer(org.gradle.tooling.internal.provider.serialization.PayloadSerializer) TestExecutionException(org.gradle.api.tasks.testing.TestExecutionException) InternalTestExecutionException(org.gradle.tooling.internal.protocol.test.InternalTestExecutionException) BuildActionResult(org.gradle.tooling.internal.provider.BuildActionResult) InternalTestExecutionException(org.gradle.tooling.internal.protocol.test.InternalTestExecutionException) ReportedException(org.gradle.initialization.ReportedException)

Example 3 with BuildActionResult

use of org.gradle.tooling.internal.provider.BuildActionResult in project gradle by gradle.

the class ClientProvidedBuildActionRunner method buildResult.

private BuildActionResult buildResult(InternalBuildAction<?> clientAction, GradleInternal gradle, boolean isRunTasks) {
    if (!isRunTasks) {
        forceFullConfiguration(gradle);
    }
    InternalBuildController internalBuildController = new DefaultBuildController(gradle);
    Object model = null;
    Throwable failure = null;
    try {
        model = clientAction.execute(internalBuildController);
    } catch (BuildCancelledException e) {
        failure = new InternalBuildCancelledException(e);
    } catch (RuntimeException e) {
        failure = new InternalBuildActionFailureException(e);
    }
    PayloadSerializer payloadSerializer = getPayloadSerializer(gradle);
    if (failure != null) {
        return new BuildActionResult(null, payloadSerializer.serialize(failure));
    } else {
        return new BuildActionResult(payloadSerializer.serialize(model), null);
    }
}
Also used : InternalBuildController(org.gradle.tooling.internal.protocol.InternalBuildController) PayloadSerializer(org.gradle.tooling.internal.provider.serialization.PayloadSerializer) InternalBuildActionFailureException(org.gradle.tooling.internal.protocol.InternalBuildActionFailureException) BuildActionResult(org.gradle.tooling.internal.provider.BuildActionResult) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException) BuildCancelledException(org.gradle.api.BuildCancelledException) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException)

Aggregations

BuildActionResult (org.gradle.tooling.internal.provider.BuildActionResult)3 PayloadSerializer (org.gradle.tooling.internal.provider.serialization.PayloadSerializer)3 BuildCancelledException (org.gradle.api.BuildCancelledException)2 InternalBuildActionFailureException (org.gradle.tooling.internal.protocol.InternalBuildActionFailureException)2 InternalBuildCancelledException (org.gradle.tooling.internal.protocol.InternalBuildCancelledException)2 GradleInternal (org.gradle.api.internal.GradleInternal)1 TestExecutionException (org.gradle.api.tasks.testing.TestExecutionException)1 ReportedException (org.gradle.initialization.ReportedException)1 InternalBuildActionVersion2 (org.gradle.tooling.internal.protocol.InternalBuildActionVersion2)1 InternalBuildController (org.gradle.tooling.internal.protocol.InternalBuildController)1 InternalTestExecutionException (org.gradle.tooling.internal.protocol.test.InternalTestExecutionException)1 TestExecutionRequestAction (org.gradle.tooling.internal.provider.TestExecutionRequestAction)1