Search in sources :

Example 1 with InternalTestExecutionConnection

use of org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection 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);
}
Also used : InternalTestExecutionConnection(org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection) BuildCancellationTokenAdapter(org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter)

Example 2 with InternalTestExecutionConnection

use of org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection in project gradle by gradle.

the class DefaultToolingImplementationLoader method create.

public ConsumerConnection create(Distribution distribution, ProgressLoggerFactory progressLoggerFactory, InternalBuildProgressListener progressListener, ConnectionParameters connectionParameters, BuildCancellationToken cancellationToken) {
    LOGGER.debug("Using tooling provider from {}", distribution.getDisplayName());
    ClassLoader serviceClassLoader = createImplementationClassLoader(distribution, progressLoggerFactory, progressListener, connectionParameters.getGradleUserHomeDir(), cancellationToken);
    ServiceLocator serviceLocator = new DefaultServiceLocator(serviceClassLoader);
    try {
        Factory<ConnectionVersion4> factory = serviceLocator.findFactory(ConnectionVersion4.class);
        if (factory == null) {
            return new NoToolingApiConnection(distribution);
        }
        // ConnectionVersion4 is a part of the protocol and cannot be easily changed.
        ConnectionVersion4 connection = factory.create();
        ProtocolToModelAdapter adapter = new ProtocolToModelAdapter(new ConsumerTargetTypeProvider());
        ModelMapping modelMapping = new ModelMapping();
        // Adopting the connection to a refactoring friendly type that the consumer owns
        if (connection instanceof InternalParameterAcceptingConnection) {
            return createConnection(new ParameterAcceptingConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof InternalTestExecutionConnection) {
            return createConnection(new TestExecutionConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof StoppableConnection) {
            return createDeprecatedConnection(new ShutdownAwareConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof InternalCancellableConnection) {
            return createDeprecatedConnection(new CancellableConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof ModelBuilder && connection instanceof InternalBuildActionExecutor) {
            return createDeprecatedConnection(new ActionAwareConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof ModelBuilder) {
            return createDeprecatedConnection(new ModelBuilderBackedConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof BuildActionRunner) {
            return createDeprecatedConnection(new BuildActionRunnerBackedConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else {
            return new UnsupportedOlderVersionConnection(connection, adapter);
        }
    } catch (UnsupportedVersionException e) {
        throw e;
    } catch (Throwable t) {
        throw new GradleConnectionException(String.format("Could not create an instance of Tooling API implementation using the specified %s.", distribution.getDisplayName()), t);
    }
}
Also used : NoToolingApiConnection(org.gradle.tooling.internal.consumer.connection.NoToolingApiConnection) ShutdownAwareConsumerConnection(org.gradle.tooling.internal.consumer.connection.ShutdownAwareConsumerConnection) UnsupportedOlderVersionConnection(org.gradle.tooling.internal.consumer.connection.UnsupportedOlderVersionConnection) TestExecutionConsumerConnection(org.gradle.tooling.internal.consumer.connection.TestExecutionConsumerConnection) DefaultServiceLocator(org.gradle.internal.service.DefaultServiceLocator) BuildActionRunner(org.gradle.tooling.internal.protocol.BuildActionRunner) ModelBuilder(org.gradle.tooling.internal.protocol.ModelBuilder) ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) CancellableConsumerConnection(org.gradle.tooling.internal.consumer.connection.CancellableConsumerConnection) FilteringClassLoader(org.gradle.internal.classloader.FilteringClassLoader) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) BuildActionRunnerBackedConsumerConnection(org.gradle.tooling.internal.consumer.connection.BuildActionRunnerBackedConsumerConnection) InternalTestExecutionConnection(org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection) ConsumerTargetTypeProvider(org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider) StoppableConnection(org.gradle.tooling.internal.protocol.StoppableConnection) ActionAwareConsumerConnection(org.gradle.tooling.internal.consumer.connection.ActionAwareConsumerConnection) GradleConnectionException(org.gradle.tooling.GradleConnectionException) ModelBuilderBackedConsumerConnection(org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection) InternalCancellableConnection(org.gradle.tooling.internal.protocol.InternalCancellableConnection) InternalParameterAcceptingConnection(org.gradle.tooling.internal.protocol.InternalParameterAcceptingConnection) ModelMapping(org.gradle.tooling.internal.consumer.versioning.ModelMapping) InternalBuildActionExecutor(org.gradle.tooling.internal.protocol.InternalBuildActionExecutor) ParameterAcceptingConsumerConnection(org.gradle.tooling.internal.consumer.connection.ParameterAcceptingConsumerConnection) DefaultServiceLocator(org.gradle.internal.service.DefaultServiceLocator) ServiceLocator(org.gradle.internal.service.ServiceLocator) ConnectionVersion4(org.gradle.tooling.internal.protocol.ConnectionVersion4) UnsupportedVersionException(org.gradle.tooling.UnsupportedVersionException)

Aggregations

InternalTestExecutionConnection (org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection)2 FilteringClassLoader (org.gradle.internal.classloader.FilteringClassLoader)1 VisitableURLClassLoader (org.gradle.internal.classloader.VisitableURLClassLoader)1 DefaultServiceLocator (org.gradle.internal.service.DefaultServiceLocator)1 ServiceLocator (org.gradle.internal.service.ServiceLocator)1 GradleConnectionException (org.gradle.tooling.GradleConnectionException)1 UnsupportedVersionException (org.gradle.tooling.UnsupportedVersionException)1 ProtocolToModelAdapter (org.gradle.tooling.internal.adapter.ProtocolToModelAdapter)1 ActionAwareConsumerConnection (org.gradle.tooling.internal.consumer.connection.ActionAwareConsumerConnection)1 BuildActionRunnerBackedConsumerConnection (org.gradle.tooling.internal.consumer.connection.BuildActionRunnerBackedConsumerConnection)1 CancellableConsumerConnection (org.gradle.tooling.internal.consumer.connection.CancellableConsumerConnection)1 ModelBuilderBackedConsumerConnection (org.gradle.tooling.internal.consumer.connection.ModelBuilderBackedConsumerConnection)1 NoToolingApiConnection (org.gradle.tooling.internal.consumer.connection.NoToolingApiConnection)1 ParameterAcceptingConsumerConnection (org.gradle.tooling.internal.consumer.connection.ParameterAcceptingConsumerConnection)1 ShutdownAwareConsumerConnection (org.gradle.tooling.internal.consumer.connection.ShutdownAwareConsumerConnection)1 TestExecutionConsumerConnection (org.gradle.tooling.internal.consumer.connection.TestExecutionConsumerConnection)1 UnsupportedOlderVersionConnection (org.gradle.tooling.internal.consumer.connection.UnsupportedOlderVersionConnection)1 ConsumerTargetTypeProvider (org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider)1 BuildCancellationTokenAdapter (org.gradle.tooling.internal.consumer.parameters.BuildCancellationTokenAdapter)1 ModelMapping (org.gradle.tooling.internal.consumer.versioning.ModelMapping)1