Search in sources :

Example 1 with ConsumerTargetTypeProvider

use of org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider in project gradle by gradle.

the class InternalBuildActionAdapter method execute.

/**
 * This is used by providers 1.8-rc-1 to 4.3
 */
public T execute(final InternalBuildController buildController) {
    ProtocolToModelAdapter protocolToModelAdapter = new ProtocolToModelAdapter(new ConsumerTargetTypeProvider());
    BuildController buildControllerAdapter = new BuildControllerAdapter(protocolToModelAdapter, new InternalBuildControllerAdapter() {

        @Override
        public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier, Object parameter) {
            return buildController.getModel(target, modelIdentifier);
        }
    }, new ModelMapping(), rootDir);
    buildControllerAdapter = new BuildControllerWithoutParameterSupport(versionDetails, buildControllerAdapter);
    if (!versionDetails.maySupportModel(BuildInvocations.class)) {
        buildControllerAdapter = new BuildInvocationsAdapterController(protocolToModelAdapter, buildControllerAdapter);
    }
    return action.execute(buildControllerAdapter);
}
Also used : ConsumerTargetTypeProvider(org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider) BuildInvocations(org.gradle.tooling.model.gradle.BuildInvocations) BuildController(org.gradle.tooling.BuildController) InternalBuildController(org.gradle.tooling.internal.protocol.InternalBuildController) ModelMapping(org.gradle.tooling.internal.consumer.versioning.ModelMapping) BuildResult(org.gradle.tooling.internal.protocol.BuildResult) ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) ModelIdentifier(org.gradle.tooling.internal.protocol.ModelIdentifier)

Example 2 with ConsumerTargetTypeProvider

use of org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider in project gradle by gradle.

the class InternalBuildActionAdapter method execute.

/**
 * This is used by providers 1.8-rc-1 to 4.3
 */
@Override
public T execute(final org.gradle.tooling.internal.protocol.InternalBuildController buildController) {
    ProtocolToModelAdapter protocolToModelAdapter = new ProtocolToModelAdapter(new ConsumerTargetTypeProvider());
    BuildController buildControllerAdapter = new BuildControllerWithoutParameterSupport(buildController, protocolToModelAdapter, new ModelMapping(), rootDir, versionDetails);
    return action.execute(buildControllerAdapter);
}
Also used : ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) ConsumerTargetTypeProvider(org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider) InternalActionAwareBuildController(org.gradle.tooling.internal.protocol.InternalActionAwareBuildController) BuildController(org.gradle.tooling.BuildController) ModelMapping(org.gradle.tooling.internal.consumer.versioning.ModelMapping)

Example 3 with ConsumerTargetTypeProvider

use of org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider in project gradle by gradle.

the class InternalBuildActionAdapter method execute.

/**
 * This is used by providers 4.4 and later
 */
public T execute(final InternalBuildControllerVersion2 buildController) {
    ProtocolToModelAdapter protocolToModelAdapter = new ProtocolToModelAdapter(new ConsumerTargetTypeProvider());
    BuildController buildControllerAdapter = new BuildControllerAdapter(protocolToModelAdapter, new InternalBuildControllerAdapter() {

        @Override
        public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier, Object parameter) {
            return buildController.getModel(target, modelIdentifier, parameter);
        }
    }, new ModelMapping(), rootDir);
    return action.execute(buildControllerAdapter);
}
Also used : BuildResult(org.gradle.tooling.internal.protocol.BuildResult) ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) ConsumerTargetTypeProvider(org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider) ModelIdentifier(org.gradle.tooling.internal.protocol.ModelIdentifier) BuildController(org.gradle.tooling.BuildController) InternalBuildController(org.gradle.tooling.internal.protocol.InternalBuildController) ModelMapping(org.gradle.tooling.internal.consumer.versioning.ModelMapping)

Example 4 with ConsumerTargetTypeProvider

use of org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider in project gradle by gradle.

the class DefaultToolingImplementationLoader method create.

@Override
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, cancellationToken);
    ServiceLocator serviceLocator = new DefaultServiceLocator(serviceClassLoader);
    try {
        Factory<ConnectionVersion4> factory = serviceLocator.findFactory(ConnectionVersion4.class);
        if (factory == null) {
            return new NoToolingApiConnection(distribution);
        }
        ConnectionVersion4 connection = factory.create();
        ProtocolToModelAdapter adapter = new ProtocolToModelAdapter(new ConsumerTargetTypeProvider());
        ModelMapping modelMapping = new ModelMapping();
        if (connection instanceof InternalStopWhenIdleConnection) {
            return createConnection(new StopWhenIdleConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof InternalInvalidatableVirtualFileSystemConnection) {
            return createConnection(new NotifyDaemonsAboutChangedPathsConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else if (connection instanceof InternalPhasedActionConnection) {
            return createConnection(new PhasedActionAwareConsumerConnection(connection, modelMapping, adapter), connectionParameters);
        } else 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 {
            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) InternalStopWhenIdleConnection(org.gradle.tooling.internal.protocol.InternalStopWhenIdleConnection) PhasedActionAwareConsumerConnection(org.gradle.tooling.internal.consumer.connection.PhasedActionAwareConsumerConnection) InternalTestExecutionConnection(org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection) UnsupportedOlderVersionConnection(org.gradle.tooling.internal.consumer.connection.UnsupportedOlderVersionConnection) TestExecutionConsumerConnection(org.gradle.tooling.internal.consumer.connection.TestExecutionConsumerConnection) ConsumerTargetTypeProvider(org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider) GradleConnectionException(org.gradle.tooling.GradleConnectionException) DefaultServiceLocator(org.gradle.internal.service.DefaultServiceLocator) InternalParameterAcceptingConnection(org.gradle.tooling.internal.protocol.InternalParameterAcceptingConnection) ModelMapping(org.gradle.tooling.internal.consumer.versioning.ModelMapping) 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) StopWhenIdleConsumerConnection(org.gradle.tooling.internal.consumer.connection.StopWhenIdleConsumerConnection) ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) NotifyDaemonsAboutChangedPathsConsumerConnection(org.gradle.tooling.internal.consumer.connection.NotifyDaemonsAboutChangedPathsConsumerConnection) FilteringClassLoader(org.gradle.internal.classloader.FilteringClassLoader) VisitableURLClassLoader(org.gradle.internal.classloader.VisitableURLClassLoader) InternalInvalidatableVirtualFileSystemConnection(org.gradle.tooling.internal.protocol.InternalInvalidatableVirtualFileSystemConnection) InternalPhasedActionConnection(org.gradle.tooling.internal.protocol.InternalPhasedActionConnection) UnsupportedVersionException(org.gradle.tooling.UnsupportedVersionException)

Aggregations

ProtocolToModelAdapter (org.gradle.tooling.internal.adapter.ProtocolToModelAdapter)4 ConsumerTargetTypeProvider (org.gradle.tooling.internal.consumer.converters.ConsumerTargetTypeProvider)4 ModelMapping (org.gradle.tooling.internal.consumer.versioning.ModelMapping)4 BuildController (org.gradle.tooling.BuildController)3 BuildResult (org.gradle.tooling.internal.protocol.BuildResult)2 InternalBuildController (org.gradle.tooling.internal.protocol.InternalBuildController)2 ModelIdentifier (org.gradle.tooling.internal.protocol.ModelIdentifier)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 NoToolingApiConnection (org.gradle.tooling.internal.consumer.connection.NoToolingApiConnection)1 NotifyDaemonsAboutChangedPathsConsumerConnection (org.gradle.tooling.internal.consumer.connection.NotifyDaemonsAboutChangedPathsConsumerConnection)1 ParameterAcceptingConsumerConnection (org.gradle.tooling.internal.consumer.connection.ParameterAcceptingConsumerConnection)1 PhasedActionAwareConsumerConnection (org.gradle.tooling.internal.consumer.connection.PhasedActionAwareConsumerConnection)1 StopWhenIdleConsumerConnection (org.gradle.tooling.internal.consumer.connection.StopWhenIdleConsumerConnection)1 TestExecutionConsumerConnection (org.gradle.tooling.internal.consumer.connection.TestExecutionConsumerConnection)1 UnsupportedOlderVersionConnection (org.gradle.tooling.internal.consumer.connection.UnsupportedOlderVersionConnection)1