@Override public void importData( @NotNull Collection<DataNode<LibraryDependencyData>> toImport, @NotNull Project project, boolean synchronous) { if (toImport.isEmpty()) { return; } Map<DataNode<ModuleData>, List<DataNode<LibraryDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toImport, MODULE); for (Map.Entry<DataNode<ModuleData>, List<DataNode<LibraryDependencyData>>> entry : byModule.entrySet()) { Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { myModuleManager.importData(Collections.singleton(entry.getKey()), project, true); module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project); if (module == null) { LOG.warn( String.format( "Can't import library dependencies %s. Reason: target module (%s) is not found at the ide and can't be imported", entry.getValue(), entry.getKey())); continue; } } importData(entry.getValue(), module, synchronous); } }
@Override protected void processData( @NotNull final Collection<DataNode<ModuleData>> nodes, @NotNull Project project) { if (nodes.isEmpty()) { return; } ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner(); ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId); assert manager != null; final MultiMap<DataNode<ProjectData>, DataNode<ModuleData>> grouped = ExternalSystemApiUtil.groupBy(nodes, ProjectKeys.PROJECT); Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> data = ContainerUtilRt.newHashMap(); for (Map.Entry<DataNode<ProjectData>, Collection<DataNode<ModuleData>>> entry : grouped.entrySet()) { data.put( ExternalProjectPojo.from(entry.getKey().getData()), ContainerUtilRt.map2List(entry.getValue(), MAPPER)); } AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project); Set<String> pathsToForget = detectRenamedProjects(data, settings.getAvailableProjects()); if (!pathsToForget.isEmpty()) { settings.forgetExternalProjects(pathsToForget); } Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> projects = ContainerUtilRt.newHashMap(settings.getAvailableProjects()); projects.putAll(data); settings.setAvailableProjects(projects); }
@Override public void importData( @NotNull Collection<DataNode<ModuleDependencyData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull PlatformFacade platformFacade, boolean synchronous) { MultiMap<DataNode<ModuleData>, DataNode<ModuleDependencyData>> byModule = ExternalSystemApiUtil.groupBy(toImport, MODULE); for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> entry : byModule.entrySet()) { Module ideModule = platformFacade.findIdeModule(entry.getKey().getData(), project); if (ideModule == null) { LOG.warn( String.format( "Can't import module dependencies %s. Reason: target module (%s) is not found at the ide and can't be imported", entry.getValue(), entry.getKey())); continue; } importData(entry.getValue(), ideModule, platformFacade, synchronous); } }