Set<ExternalDependency> (@NotNull final Configuration configuration, @NotNull final Collection<Dependency> dependencies, @Nullable final String scope) { Set<ExternalDependency> result = new LinkedHashSet<>(); Set<ResolvedArtifact> resolvedArtifacts = myIsPreview ? Collections.emptySet() : configuration.getResolvedConfiguration().getLenientConfiguration() .getArtifacts(Specs.SATISFIES_ALL); Multimap<MyModuleIdentifier, ResolvedArtifact> artifactMap = ArrayListMultimap.create(); for (ResolvedArtifact artifact : resolvedArtifacts) { artifactMap.put(toMyModuleIdentifier(artifact.getModuleVersion().getId()), artifact); } GradleSourceSetCachedFinder sourceSetFinder = GradleSourceSetCachedFinder.getInstance(myContext); for (Dependency it : dependencies) { try { if (it instanceof ProjectDependency) { Project project = ((ProjectDependency)it).getDependencyProject(); Configuration targetConfiguration = getTargetConfiguration((ProjectDependency)it); DefaultExternalProjectDependency projectDependency = new DefaultExternalProjectDependency(); projectDependency.setName(project.getName()); projectDependency.setGroup(project.getGroup().toString()); projectDependency.setVersion(project.getVersion().toString()); projectDependency.setScope(scope); projectDependency.setProjectPath(project.getPath()); projectDependency.setConfigurationName(targetConfiguration == null ? "default" : targetConfiguration.getName()); Set<File> artifacts = new LinkedHashSet<>(targetConfiguration == null ? Collections.emptySet() : targetConfiguration.getAllArtifacts().getFiles().getFiles()); projectDependency.setProjectDependencyArtifacts(artifacts); projectDependency.setProjectDependencyArtifactsSources(sourceSetFinder.findArtifactSources(artifacts)); result.add(projectDependency); } else if (it != null) { Collection<ResolvedArtifact> artifactsResult = artifactMap.get(toMyModuleIdentifier(it.getName(), it.getGroup())); if (!artifactsResult.isEmpty()) { ResolvedArtifact artifact = artifactsResult.iterator().next(); String packaging = artifact.getExtension(); String classifier = artifact.getClassifier(); final ExternalLibraryDependency resolvedDep = resolveLibraryByPath(artifact.getFile(), scope); File sourcesFile = resolvedDep == null ? null : resolvedDep.getSource(); DefaultExternalLibraryDependency libraryDependency = new DefaultExternalLibraryDependency(); libraryDependency.setName(it.getName()); libraryDependency.setGroup(it.getGroup()); libraryDependency.setPackaging(packaging); libraryDependency.setClassifier(classifier); libraryDependency.setVersion(artifact.getModuleVersion().getId().getVersion()); libraryDependency.setScope(scope); libraryDependency.setFile(artifact.getFile()); libraryDependency.setSource(sourcesFile); result.add(libraryDependency); } else { if (!(it instanceof SelfResolvingDependency) && !myIsPreview) { final DefaultUnresolvedExternalDependency dependency = new DefaultUnresolvedExternalDependency(); dependency.setName(it.getName()); dependency.setGroup(it.getGroup()); dependency.setVersion(it.getVersion()); dependency.setScope(scope); dependency.setFailureMessage("Could not find " + it.getGroup() + ":" + it.getName() + ":" + it.getVersion()); result.add(dependency); } } } } catch (Exception e) { // ignore } } return result; }