private static @NotNull LibraryOrderEntry syncExistingLibraryDependency(@NotNull IdeModifiableModelsProvider modelsProvider,
                                                                          @NotNull final LibraryDependencyData libraryDependencyData,
                                                                          @NotNull final Library library,
                                                                          @NotNull final ModifiableRootModel moduleRootModel,
                                                                          @NotNull final Module module,
                                                                          @Nullable LibraryOrderEntry currentRegisteredLibraryOrderEntry) {
    final Library.ModifiableModel libraryModel = modelsProvider.getModifiableLibraryModel(library);
    final String libraryName = libraryDependencyData.getInternalName();
    final LibraryData libraryDependencyDataTarget = libraryDependencyData.getTarget();
    Map<OrderRootType, Collection<File>> files = LibraryDataService.prepareLibraryFiles(libraryDependencyDataTarget);
    Set<String> excludedPaths = libraryDependencyDataTarget.getPaths(LibraryPathType.EXCLUDED);
    LibraryDataService.registerPaths(libraryDependencyDataTarget.isUnresolved(), files, excludedPaths, libraryModel, libraryName);
    LibraryOrderEntry orderEntry = currentRegisteredLibraryOrderEntry;
    if (orderEntry == null) {
      orderEntry = findLibraryOrderEntry(moduleRootModel, library, libraryDependencyData.getScope());
    }

    assert orderEntry != null;
    setLibraryScope(orderEntry, library, module, libraryDependencyData);
    return orderEntry;
  }
private static @NotNull LibraryOrderEntry syncExistingLibraryDependency(@NotNull IdeModifiableModelsProvider modelsProvider,
                                                                          @NotNull final LibraryDependencyData libraryDependencyData,
                                                                          @NotNull final Library library,
                                                                          @NotNull final ModifiableRootModel moduleRootModel,
                                                                          @NotNull final Module module,
                                                                          @Nullable LibraryOrderEntry currentRegisteredLibraryOrderEntry)