Search in sources :

Example 1 with ProtocolToModelAdapter

use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter in project gradle by gradle.

the class Inspector method unpack.

private void unpack(Object library, Map<Object, Object> objectMap) {
    Object unpacked = new ProtocolToModelAdapter().unpack(library);
    objectMap.put(unpacked, unpacked);
}
Also used : ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter)

Example 2 with ProtocolToModelAdapter

use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter in project gradle by gradle.

the class DefaultBuildController method getParameterizedModel.

private <T> Object getParameterizedModel(ProjectInternal project, String modelName, ParameterizedToolingModelBuilder<T> builder, Object parameter) throws InternalUnsupportedModelException {
    Class<T> expectedParameterType = builder.getParameterType();
    ViewBuilder<T> viewBuilder = new ProtocolToModelAdapter().builder(expectedParameterType);
    T internalParameter = viewBuilder.build(parameter);
    return builder.buildAll(modelName, internalParameter, project);
}
Also used : ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter)

Example 3 with ProtocolToModelAdapter

use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter 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 4 with ProtocolToModelAdapter

use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter 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 5 with ProtocolToModelAdapter

use of org.gradle.tooling.internal.adapter.ProtocolToModelAdapter in project intellij-community by JetBrains.

the class ProjectImportAction method configureAdditionalTypes.

private static void configureAdditionalTypes(BuildController controller) {
    try {
        Field adapterField = controller.getClass().getDeclaredField("adapter");
        adapterField.setAccessible(true);
        ProtocolToModelAdapter adapter = (ProtocolToModelAdapter) adapterField.get(controller);
        Field typeProviderField = adapter.getClass().getDeclaredField("targetTypeProvider");
        typeProviderField.setAccessible(true);
        TargetTypeProvider typeProvider = (TargetTypeProvider) typeProviderField.get(adapter);
        Field targetTypesField = typeProvider.getClass().getDeclaredField("configuredTargetTypes");
        targetTypesField.setAccessible(true);
        //noinspection unchecked
        Map<String, Class<?>> targetTypes = (Map<String, Class<?>>) targetTypesField.get(typeProvider);
        targetTypes.put(ExternalProjectDependency.class.getCanonicalName(), ExternalProjectDependency.class);
        targetTypes.put(ExternalLibraryDependency.class.getCanonicalName(), ExternalLibraryDependency.class);
        targetTypes.put(FileCollectionDependency.class.getCanonicalName(), FileCollectionDependency.class);
        targetTypes.put(UnresolvedExternalDependency.class.getCanonicalName(), UnresolvedExternalDependency.class);
    } catch (Exception ignore) {
    // TODO handle error
    }
}
Also used : Field(java.lang.reflect.Field) ProtocolToModelAdapter(org.gradle.tooling.internal.adapter.ProtocolToModelAdapter) TargetTypeProvider(org.gradle.tooling.internal.adapter.TargetTypeProvider) ExternalSystemException(com.intellij.openapi.externalSystem.model.ExternalSystemException)

Aggregations

ProtocolToModelAdapter (org.gradle.tooling.internal.adapter.ProtocolToModelAdapter)8 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 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 BuildLayoutParameters (org.gradle.initialization.BuildLayoutParameters)1 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 TargetTypeProvider (org.gradle.tooling.internal.adapter.TargetTypeProvider)1 NoToolingApiConnection (org.gradle.tooling.internal.consumer.connection.NoToolingApiConnection)1 NotifyDaemonsAboutChangedPathsConsumerConnection (org.gradle.tooling.internal.consumer.connection.NotifyDaemonsAboutChangedPathsConsumerConnection)1