@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); } }
private void processOrphanProjectLibraries() { PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class); List<Library> orphanIdeLibraries = ContainerUtilRt.newArrayList(); LibraryTable projectLibraryTable = platformFacade.getProjectLibraryTable(myProject); for (Library library : projectLibraryTable.getLibraries()) { if (!ExternalSystemApiUtil.isExternalSystemLibrary(library, myExternalSystemId)) continue; if (ProjectStructureHelper.isOrphanProjectLibrary( library, platformFacade.getModules(myProject))) { orphanIdeLibraries.add(library); } } for (Library orphanIdeLibrary : orphanIdeLibraries) { projectLibraryTable.removeLibrary(orphanIdeLibrary); } }