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