public static Promise<List<OrderRoot>> loadDependenciesToLibrary(@NotNull final Project project,
                                                                   @NotNull final LibraryEx library,
                                                                   boolean downloadSources,
                                                                   boolean downloadJavaDocs,
                                                                   @Nullable String copyTo) {
    if (library.getKind() != RepositoryLibraryType.REPOSITORY_LIBRARY_KIND) {
      return resolvedPromise(Collections.emptyList());
    }
    final RepositoryLibraryProperties properties = (RepositoryLibraryProperties)library.getProperties();
    String[] annotationUrls = library.getUrls(AnnotationOrderRootType.getInstance());
    String[] excludedRootUrls = library.getExcludedRootUrls();

    return JarRepositoryManager.loadDependenciesAsync(
      project, properties, downloadSources, downloadJavaDocs, null, copyTo).thenAsync(roots -> {

        if (roots == null || roots.isEmpty()) {
          ApplicationManager.getApplication().invokeLater(() -> {
            RepositoryLibraryResolveErrorNotification.showOrUpdate(properties, project);
          });

          return rejectedPromise("Library '" + properties.getMavenId() + "' resolution failed");
        }
        else {
          LOG.debug("Loaded dependencies for '" + properties.getMavenId() + "' repository library");

          return setupLibraryRoots(library, properties, annotationUrls, excludedRootUrls, roots).then(ignored -> roots);
        }
    });
  }
public static Promise<List<OrderRoot>> loadDependenciesToLibrary(@NotNull final Project project,
                                                                   @NotNull final LibraryEx library,
                                                                   boolean downloadSources,
                                                                   boolean downloadJavaDocs,
                                                                   @Nullable String copyTo)