Search in sources :

Example 1 with InternalBuildCancelledException

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

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

Example 3 with InternalBuildCancelledException

use of org.gradle.tooling.internal.protocol.InternalBuildCancelledException in project gradle by gradle.

the class ClientProvidedBuildActionRunner method forceFullConfiguration.

private void forceFullConfiguration(GradleInternal gradle) {
    try {
        gradle.getServices().get(ProjectConfigurer.class).configureHierarchyFully(gradle.getRootProject());
        for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
            GradleInternal build = ((IncludedBuildInternal) includedBuild).getConfiguredBuild();
            forceFullConfiguration(build);
        }
    } catch (BuildCancelledException e) {
        throw new InternalBuildCancelledException(e);
    } catch (RuntimeException e) {
        throw new BuildExceptionVersion1(e);
    }
}
Also used : IncludedBuildInternal(org.gradle.composite.internal.IncludedBuildInternal) GradleInternal(org.gradle.api.internal.GradleInternal) BuildExceptionVersion1(org.gradle.tooling.internal.protocol.BuildExceptionVersion1) ProjectConfigurer(org.gradle.execution.ProjectConfigurer) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException) BuildCancelledException(org.gradle.api.BuildCancelledException) IncludedBuild(org.gradle.api.initialization.IncludedBuild) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException)

Example 4 with InternalBuildCancelledException

use of org.gradle.tooling.internal.protocol.InternalBuildCancelledException in project gradle by gradle.

the class DaemonBuildActionExecuter method execute.

public Object execute(BuildAction action, BuildRequestContext buildRequestContext, ProviderOperationParameters parameters, ServiceRegistry contextServices) {
    boolean continuous = action.getStartParameter() != null && action.getStartParameter().isContinuous() && isNotBuildingModel(action);
    if (continuous && !doesConsumerSupportCancellation(buildRequestContext)) {
        throw new UnsupportedVersionException("Continuous build requires Tooling API client version 2.1 or later.");
    }
    ClassPath classPath = DefaultClassPath.of(parameters.getInjectedPluginClasspath(Collections.<File>emptyList()));
    BuildActionParameters actionParameters = new DefaultBuildActionParameters(daemonParameters.getEffectiveSystemProperties(), daemonParameters.getEnvironmentVariables(), SystemProperties.getInstance().getCurrentDir(), parameters.getBuildLogLevel(), daemonParameters.isEnabled(), continuous, false, classPath);
    try {
        return executer.execute(action, buildRequestContext, actionParameters, contextServices);
    } catch (ReportedException e) {
        Throwable t = e.getCause();
        // Unpack tunnelled test request failure
        if (t instanceof InternalTestExecutionException) {
            throw (InternalTestExecutionException) t;
        }
        while (t != null) {
            if (t instanceof BuildCancelledException) {
                throw new InternalBuildCancelledException(e.getCause());
            }
            t = t.getCause();
        }
        throw new BuildExceptionVersion1(e.getCause());
    }
}
Also used : DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) ClassPath(org.gradle.internal.classpath.ClassPath) BuildExceptionVersion1(org.gradle.tooling.internal.protocol.BuildExceptionVersion1) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) InternalTestExecutionException(org.gradle.tooling.internal.protocol.test.InternalTestExecutionException) File(java.io.File) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException) BuildCancelledException(org.gradle.api.BuildCancelledException) UnsupportedVersionException(org.gradle.tooling.UnsupportedVersionException) ReportedException(org.gradle.initialization.ReportedException) InternalBuildCancelledException(org.gradle.tooling.internal.protocol.InternalBuildCancelledException)

Aggregations

BuildCancelledException (org.gradle.api.BuildCancelledException)4 InternalBuildCancelledException (org.gradle.tooling.internal.protocol.InternalBuildCancelledException)4 BuildExceptionVersion1 (org.gradle.tooling.internal.protocol.BuildExceptionVersion1)2 InternalBuildActionFailureException (org.gradle.tooling.internal.protocol.InternalBuildActionFailureException)2 BuildActionResult (org.gradle.tooling.internal.provider.BuildActionResult)2 PayloadSerializer (org.gradle.tooling.internal.provider.serialization.PayloadSerializer)2 File (java.io.File)1 IncludedBuild (org.gradle.api.initialization.IncludedBuild)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 IncludedBuildInternal (org.gradle.composite.internal.IncludedBuildInternal)1 ProjectConfigurer (org.gradle.execution.ProjectConfigurer)1 ReportedException (org.gradle.initialization.ReportedException)1 ClassPath (org.gradle.internal.classpath.ClassPath)1 DefaultClassPath (org.gradle.internal.classpath.DefaultClassPath)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)1 UnsupportedVersionException (org.gradle.tooling.UnsupportedVersionException)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