private static void importLibrary(final @NotNull LibraryData toImport, final @NotNull IdeModifiableModelsProvider modelsProvider) {
    final String libraryName = toImport.getInternalName();
    Library library = modelsProvider.getLibraryByName(libraryName);
    ProjectModelExternalSource source = ExternalSystemApiUtil.toExternalSource(toImport.getOwner());
    if (library != null) {
      if (library.getExternalSource() == null) {
        ((LibraryEx.ModifiableModelEx)modelsProvider.getModifiableLibraryModel(library)).setExternalSource(source);
      }
      syncPaths(toImport, library, modelsProvider);
      return;
    }
    LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel();
    library = librariesModel.createLibrary(libraryName, getLibraryKind(toImport), source);
    Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(library);
    prepareNewLibrary(toImport, libraryName, libraryModel);
  }
private static void importLibrary(final @NotNull LibraryData toImport, final @NotNull IdeModifiableModelsProvider modelsProvider)