private static void createOrUpdateLibrary(@NotNull final String libraryName,
@NotNull final List<Pair<VirtualFile, DownloadableFileDescription>> pairs) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Library library = ApplicationLibraryTable.getApplicationTable().getLibraryByName(libraryName);
if (library == null) {
LibraryTable.ModifiableModel modifiableModel = ApplicationLibraryTable.getApplicationTable().getModifiableModel();
library = modifiableModel.createLibrary(libraryName);
modifiableModel.commit();
}
Library.ModifiableModel modifiableModel = library.getModifiableModel();
for (Pair<VirtualFile, DownloadableFileDescription> pair : pairs) {
modifiableModel.addRoot(pair.first, OrderRootType.CLASSES);
}
modifiableModel.commit();
}