use of org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter in project gradle by gradle.
the class PhasedActionAwareConsumerConnection method run.
@Override
public void run(PhasedBuildAction phasedBuildAction, ConsumerOperationParameters operationParameters) {
InternalPhasedActionConnection connection = (InternalPhasedActionConnection) getDelegate();
PhasedActionResultListener listener = new DefaultPhasedActionResultListener(getHandler(phasedBuildAction.getProjectsLoadedAction()), getHandler(phasedBuildAction.getBuildFinishedAction()));
InternalPhasedAction internalPhasedAction = getPhasedAction(phasedBuildAction, operationParameters.getProjectDir(), getVersionDetails());
try {
connection.run(internalPhasedAction, listener, new BuildCancellationTokenAdapter(operationParameters.getCancellationToken()), operationParameters);
} catch (InternalBuildActionFailureException e) {
throw new BuildActionFailureException("The supplied phased action failed with an exception.", e.getCause());
}
}
use of org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter in project gradle by gradle.
the class TestExecutionConsumerConnection method runTests.
@Override
public void runTests(final TestExecutionRequest testExecutionRequest, ConsumerOperationParameters operationParameters) {
final BuildCancellationTokenAdapter cancellationTokenAdapter = new BuildCancellationTokenAdapter(operationParameters.getCancellationToken());
((InternalTestExecutionConnection) getDelegate()).runTests(testExecutionRequest, cancellationTokenAdapter, operationParameters);
}
use of org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter in project gradle by gradle.
the class CancellableActionRunner method run.
@Override
public <T> T run(final BuildAction<T> action, ConsumerOperationParameters operationParameters) throws UnsupportedOperationException, IllegalStateException {
File rootDir = operationParameters.getProjectDir();
BuildResult<T> result;
try {
try {
result = execute(new InternalBuildActionAdapter<T>(action, rootDir, versionDetails), new BuildCancellationTokenAdapter(operationParameters.getCancellationToken()), operationParameters);
} catch (RuntimeException e) {
throw exceptionTransformer.transform(e);
}
} catch (InternalBuildActionFailureException e) {
throw new BuildActionFailureException("The supplied build action failed with an exception.", e.getCause());
}
return result.getModel();
}
use of org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter in project gradle by gradle.
the class CancellableModelBuilderBackedModelProducer method produceModel.
@Override
public <T> T produceModel(Class<T> type, ConsumerOperationParameters operationParameters) {
if (!versionDetails.maySupportModel(type)) {
throw Exceptions.unsupportedModel(type, versionDetails.getVersion());
}
final ModelIdentifier modelIdentifier = modelMapping.getModelIdentifierFromModelType(type);
BuildResult<?> result;
try {
result = builder.getModel(modelIdentifier, new BuildCancellationTokenAdapter(operationParameters.getCancellationToken()), operationParameters);
} catch (InternalUnsupportedModelException e) {
throw Exceptions.unknownModel(type, e);
} catch (RuntimeException e) {
throw exceptionTransformer.transform(e);
}
return applyCompatibilityMapping(adapter.builder(type), operationParameters).build(result.getModel());
}
Aggregations