Search in sources :

Example 1 with DefaultBuildRequestContext

use of org.gradle.initialization.DefaultBuildRequestContext in project gradle by gradle.

the class ProviderConnection method run.

private Object run(BuildAction action, BuildCancellationToken cancellationToken, ProgressListenerConfiguration progressListenerConfiguration, ProviderOperationParameters providerParameters, Parameters parameters) {
    try {
        BuildActionExecuter<ProviderOperationParameters> executer = createExecuter(providerParameters, parameters);
        BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(new DefaultBuildRequestMetaData(providerParameters.getStartTime()), cancellationToken, progressListenerConfiguration.buildEventConsumer);
        BuildActionResult result = (BuildActionResult) executer.execute(action, buildRequestContext, providerParameters, sharedServices);
        if (result.failure != null) {
            throw (RuntimeException) payloadSerializer.deserialize(result.failure);
        }
        return payloadSerializer.deserialize(result.result);
    } finally {
        progressListenerConfiguration.failsafeWrapper.rethrowErrors();
    }
}
Also used : DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) ProviderOperationParameters(org.gradle.tooling.internal.provider.connection.ProviderOperationParameters) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext)

Example 2 with DefaultBuildRequestContext

use of org.gradle.initialization.DefaultBuildRequestContext in project gradle by gradle.

the class ExecuteBuild method doBuild.

@Override
protected void doBuild(final DaemonCommandExecution execution, Build build) {
    LOGGER.debug(DaemonMessages.STARTED_BUILD);
    LOGGER.debug("Executing build with daemon context: {}", execution.getDaemonContext());
    runningStats.buildStarted();
    DaemonConnectionBackedEventConsumer buildEventConsumer = new DaemonConnectionBackedEventConsumer(execution);
    try {
        BuildCancellationToken cancellationToken = execution.getDaemonStateControl().getCancellationToken();
        BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(build.getBuildRequestMetaData(), cancellationToken, buildEventConsumer);
        if (!build.getAction().getStartParameter().isContinuous()) {
            buildRequestContext.getCancellationToken().addCallback(new Runnable() {

                @Override
                public void run() {
                    LOGGER.info(DaemonMessages.CANCELED_BUILD);
                }
            });
        }
        BuildActionResult result = actionExecuter.execute(build.getAction(), build.getParameters(), buildRequestContext);
        execution.setResult(result);
    } finally {
        buildEventConsumer.waitForFinish();
        runningStats.buildFinished();
        LOGGER.debug(DaemonMessages.FINISHED_BUILD);
    }
    // ExecuteBuild should be the last action, but in case we want to decorate the result in the future
    execution.proceed();
}
Also used : DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildActionResult(org.gradle.launcher.exec.BuildActionResult) BuildCancellationToken(org.gradle.initialization.BuildCancellationToken) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext)

Example 3 with DefaultBuildRequestContext

use of org.gradle.initialization.DefaultBuildRequestContext in project gradle by gradle.

the class ProviderConnection method run.

private Object run(BuildAction action, BuildCancellationToken cancellationToken, ProgressListenerConfiguration progressListenerConfiguration, BuildEventConsumer buildEventConsumer, ProviderOperationParameters providerParameters, Parameters parameters) {
    try {
        BuildActionExecuter<ConnectionOperationParameters, BuildRequestContext> executer = createExecuter(providerParameters, parameters);
        boolean interactive = providerParameters.getStandardInput() != null;
        BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(new DefaultBuildRequestMetaData(providerParameters.getStartTime(), interactive), cancellationToken, buildEventConsumer);
        BuildActionResult result = executer.execute(action, new ConnectionOperationParameters(parameters.daemonParams, providerParameters), buildRequestContext);
        throwFailure(result);
        return payloadSerializer.deserialize(result.getResult());
    } finally {
        progressListenerConfiguration.failsafeWrapper.rethrowErrors();
    }
}
Also used : DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) DefaultBuildRequestMetaData(org.gradle.initialization.DefaultBuildRequestMetaData) BuildActionResult(org.gradle.launcher.exec.BuildActionResult) DefaultBuildRequestContext(org.gradle.initialization.DefaultBuildRequestContext) BuildRequestContext(org.gradle.initialization.BuildRequestContext)

Aggregations

BuildRequestContext (org.gradle.initialization.BuildRequestContext)3 DefaultBuildRequestContext (org.gradle.initialization.DefaultBuildRequestContext)3 DefaultBuildRequestMetaData (org.gradle.initialization.DefaultBuildRequestMetaData)2 BuildActionResult (org.gradle.launcher.exec.BuildActionResult)2 BuildCancellationToken (org.gradle.initialization.BuildCancellationToken)1 ProviderOperationParameters (org.gradle.tooling.internal.provider.connection.ProviderOperationParameters)1