Search in sources :

Example 1 with InternalBuildActionVersion2

use of org.gradle.tooling.internal.protocol.InternalBuildActionVersion2 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)

Aggregations

BuildCancelledException (org.gradle.api.BuildCancelledException)1 InternalBuildActionFailureException (org.gradle.tooling.internal.protocol.InternalBuildActionFailureException)1 InternalBuildActionVersion2 (org.gradle.tooling.internal.protocol.InternalBuildActionVersion2)1 InternalBuildCancelledException (org.gradle.tooling.internal.protocol.InternalBuildCancelledException)1 BuildActionResult (org.gradle.tooling.internal.provider.BuildActionResult)1 PayloadSerializer (org.gradle.tooling.internal.provider.serialization.PayloadSerializer)1