void (final Library fromLibrary, final ModifiableRootModel toModel) { final LibraryTable.ModifiableModel libraryTableModel = toModel.getModuleLibraryTable().getModifiableModel(); Library library = libraryTableModel.createLibrary(null); final Library.ModifiableModel libraryModel = library.getModifiableModel(); for (OrderRootType rootType : OrderRootType.getAllTypes()) { for (String url : fromLibrary.getUrls(rootType)) { libraryModel.addRoot(url, rootType); } } libraryModel.commit(); libraryTableModel.commit(); }