use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter 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);
}
use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter in project gradle by gradle.
the class DefaultConnection method configure.
/**
* This is used by consumers 1.2-rc-1 and later.
*/
@Override
public void configure(ConnectionParameters parameters) {
assertUsingSupportedJavaVersion();
ProviderConnectionParameters providerConnectionParameters = new ProtocolToModelAdapter().adapt(ProviderConnectionParameters.class, parameters);
File gradleUserHomeDir = providerConnectionParameters.getGradleUserHomeDir(null);
if (gradleUserHomeDir == null) {
gradleUserHomeDir = new BuildLayoutParameters().getGradleUserHomeDir();
}
initializeServices(gradleUserHomeDir);
consumerVersion = GradleVersion.version(providerConnectionParameters.getConsumerVersion());
connection.configure(providerConnectionParameters, consumerVersion);
}
use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter 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);
}
}
Aggregations