private @NotNull Map<ComponentIdentifier, ComponentArtifactsResult> buildAuxiliaryArtifactsMap(
    @NotNull Configuration configuration,
    @NotNull Map<ResolvedDependency, Set<ResolvedArtifact>> resolvedArtifacts
  ) {
    List<ComponentIdentifier> components = new ArrayList<>();
    for (Collection<ResolvedArtifact> artifacts : resolvedArtifacts.values()) {
      for (ResolvedArtifact artifact : artifacts) {
        if (artifact.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier) continue;
        ModuleVersionIdentifier id = artifact.getModuleVersion().getId();
        components.add(DefaultModuleComponentIdentifier.create(id));
      }
    }

    if (components.isEmpty()) {
      return Collections.emptyMap();
    }

    List<Class<? extends Artifact>> artifactTypes = new ArrayList<>(2);
    if (myDownloadPolicy.isDownloadSources()) {
      artifactTypes.add(SourcesArtifact.class);
    }
    if (myDownloadPolicy.isDownloadJavadoc()) {
      artifactTypes.add(JavadocArtifact.class);
    }

    boolean isBuildScriptConfiguration = myProject.getBuildscript().getConfigurations().contains(configuration);
    DependencyHandler dependencyHandler =
      isBuildScriptConfiguration ? myProject.getBuildscript().getDependencies() : myProject.getDependencies();
    Set<ComponentArtifactsResult> componentResults = dependencyHandler.createArtifactResolutionQuery()
      .forComponents(components)
      .withArtifacts(JvmLibrary.class, artifactTypes)
      .execute()
      .getResolvedComponents();

    Map<ComponentIdentifier, ComponentArtifactsResult> result = new HashMap<>(componentResults.size());
    for (ComponentArtifactsResult artifactsResult : componentResults) {
      result.put(artifactsResult.getId(), artifactsResult);
    }
    return result;
  }
private @NotNull Map<ComponentIdentifier, ComponentArtifactsResult> buildAuxiliaryArtifactsMap(
    @NotNull Configuration configuration,
    @NotNull Map<ResolvedDependency, Set<ResolvedArtifact>> resolvedArtifacts
  )