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);
}
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);
}
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);
}
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);
}
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
}
}
Aggregations