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