private static @NotNull Collection<? extends ExternalDependency> mergeResolvedDependencies(
    @NotNull Collection<? extends ExternalDependency> compileDependencies,
    @NotNull Collection<? extends ExternalDependency> runtimeDependencies
  ) {
    Multimap<Collection<File>, ExternalDependency> runtimeDependencyFileIndex = HashMultimap.create();
    for (ExternalDependency dependency : runtimeDependencies) {
      Collection<File> resolvedFiles = getFiles(dependency);
      runtimeDependencyFileIndex.put(resolvedFiles, dependency);
    }
    Collection<ExternalDependency> runtimeOnlyDependencies = new LinkedHashSet<>(runtimeDependencies);
    for (ExternalDependency dependency : compileDependencies) {
      Collection<File> resolvedFiles = getFiles(dependency);
      Collection<ExternalDependency> compileAndRuntimeDependencies = runtimeDependencyFileIndex.get(resolvedFiles);
      if (compileAndRuntimeDependencies.isEmpty()) {
        ((AbstractExternalDependency)dependency).setScope(PROVIDED_SCOPE);
      }
      else {
        runtimeOnlyDependencies.removeAll(compileAndRuntimeDependencies);
      }
    }

    Collection<ExternalDependency> result = new LinkedHashSet<>();
    result.addAll(compileDependencies);
    result.addAll(runtimeOnlyDependencies);
    return result;
  }
private static @NotNull Collection<? extends ExternalDependency> mergeResolvedDependencies(
    @NotNull Collection<? extends ExternalDependency> compileDependencies,
    @NotNull Collection<? extends ExternalDependency> runtimeDependencies
  )