private static @NotNull Library createLibraryFromRoots(@NotNull List<OrderRoot> roots,
                                                         @Nullable LibraryType libraryType,
                                                         @NotNull LibraryTable.ModifiableModel moduleLibrariesModel,
                                                         @Nullable Function<? super LibraryType, ? extends LibraryProperties> defaultPropertiesFactory) {
    PersistentLibraryKind kind = libraryType == null ? null : libraryType.getKind();
    Library library = moduleLibrariesModel.createLibrary(null, kind);
    LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
    if (defaultPropertiesFactory != null) {
      libModel.setProperties(defaultPropertiesFactory.fun(libraryType));
    }
    for (OrderRoot root : roots) {
      if (root.isJarDirectory()) {
        libModel.addJarDirectory(root.getFile(), false, root.getType());
      }
      else {
        libModel.addRoot(root.getFile(), root.getType());
      }
    }
    libModel.commit();
    return library;
  }
private static @NotNull Library createLibraryFromRoots(@NotNull List<OrderRoot> roots,
                                                         @Nullable LibraryType libraryType,
                                                         @NotNull LibraryTable.ModifiableModel moduleLibrariesModel,
                                                         @Nullable Function<? super LibraryType, ? extends LibraryProperties> defaultPropertiesFactory)