use of org.gradle.initialization.BuildCancellationToken in project gradle by gradle.
the class LazyConsumerActionExecutor method run.
public <T> T run(ConsumerAction<T> action) throws UnsupportedOperationException, IllegalStateException {
try {
ConsumerOperationParameters parameters = action.getParameters();
BuildCancellationToken cancellationToken = parameters.getCancellationToken();
InternalBuildProgressListener buildProgressListener = parameters.getBuildProgressListener();
ConsumerConnection connection = onStartAction(cancellationToken, buildProgressListener);
return action.run(connection);
} finally {
onEndAction();
}
}
use of org.gradle.initialization.BuildCancellationToken in project gradle by gradle.
the class DefaultBuildController method getModel.
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class);
if (cancellationToken.isCancellationRequested()) {
throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
}
ProjectInternal project = getTargetProject(target);
ToolingModelBuilder builder = getToolingModelBuilder(project, modelIdentifier);
Object model = builder.buildAll(modelIdentifier.getName(), project);
return new ProviderBuildResult<Object>(model);
}
use of org.gradle.initialization.BuildCancellationToken in project gradle by gradle.
the class DefaultConnection method run.
/**
* This is used by consumers 2.1-rc-1 and later.
*/
public <T> BuildResult<T> run(InternalBuildAction<T> action, InternalCancellationToken cancellationToken, BuildParameters operationParameters) throws BuildExceptionVersion1, InternalUnsupportedBuildArgumentException, IllegalStateException {
ProviderOperationParameters providerParameters = validateAndConvert(operationParameters);
BuildCancellationToken buildCancellationToken = new InternalCancellationTokenAdapter(cancellationToken);
Object results = connection.run(action, buildCancellationToken, providerParameters);
return new ProviderBuildResult<T>((T) results);
}
use of org.gradle.initialization.BuildCancellationToken in project gradle by gradle.
the class DefaultConnection method runTests.
/**
* This is used by consumers 2.6-rc-1 and later
*/
public BuildResult<?> runTests(InternalTestExecutionRequest testExecutionRequest, InternalCancellationToken cancellationToken, BuildParameters operationParameters) throws BuildExceptionVersion1, InternalUnsupportedBuildArgumentException, IllegalStateException {
ProviderOperationParameters providerParameters = validateAndConvert(operationParameters);
ProviderInternalTestExecutionRequest testExecutionRequestVersion2 = adapter.adapt(ProviderInternalTestExecutionRequest.class, testExecutionRequest);
BuildCancellationToken buildCancellationToken = new InternalCancellationTokenAdapter(cancellationToken);
Object results = connection.runTests(testExecutionRequestVersion2, buildCancellationToken, providerParameters);
return new ProviderBuildResult<Object>(results);
}
use of org.gradle.initialization.BuildCancellationToken in project gradle by gradle.
the class ExecuteBuild method doBuild.
protected void doBuild(final DaemonCommandExecution execution, Build build) {
LOGGER.debug(DaemonMessages.STARTED_BUILD);
LOGGER.info("Executing build with daemon context: {}", execution.getDaemonContext());
runningStats.buildStarted();
try {
BuildCancellationToken cancellationToken = execution.getDaemonStateControl().getCancellationToken();
BuildRequestContext buildRequestContext = new DefaultBuildRequestContext(build.getBuildRequestMetaData(), cancellationToken, new DaemonConnectionBackedEventConsumer(execution));
if (!build.getParameters().isContinuous()) {
buildRequestContext.getCancellationToken().addCallback(new Runnable() {
@Override
public void run() {
LOGGER.warn(DaemonMessages.CANCELED_BUILD);
}
});
}
Object result = actionExecuter.execute(build.getAction(), buildRequestContext, build.getParameters(), contextServices);
execution.setResult(result);
} catch (ReportedException e) {
/*
We have to wrap in a ReportedException so the other side doesn't re-log this exception, because it's already
been logged by the GradleLauncher infrastructure, and that logging has been shipped over to the other side.
This doesn't seem right. Perhaps we should assume on the client side that all “build failures” (opposed to daemon infrastructure failures)
have already been logged and do away with this wrapper.
*/
execution.setException(e);
} finally {
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();
}
Aggregations