Collection<ExternalDependency> (Collection<ResolvedArtifact> resolvedArtifactToFilter, Collection<ProjectDependency> projectDepsToFilter) { Collection<ExternalDependency> result = new ArrayList<>(); Set<File> fileDeps = new LinkedHashSet<>(myConfiguration.getIncoming().getFiles().getFiles()); for (ResolvedArtifact artifact : resolvedArtifactToFilter) { fileDeps.remove(artifact.getFile()); } if (!fileDeps.isEmpty()) { for (ProjectDependency dep : projectDepsToFilter) { Configuration targetConfiguration = DeprecatedDependencyResolver.getTargetConfiguration(dep); if (targetConfiguration == null) continue; Set<File> depFiles = targetConfiguration.getAllArtifacts().getFiles().getFiles(); final Set<File> intersection = new LinkedHashSet<>(Sets.intersection(fileDeps, depFiles)); if (!intersection.isEmpty()) { DefaultFileCollectionDependency fileCollectionDependency = new DefaultFileCollectionDependency(intersection); fileCollectionDependency.setScope(myScope); result.add(fileCollectionDependency); fileDeps.removeAll(intersection); } } } for (File file : fileDeps) { DefaultFileCollectionDependency fileCollectionDependency = new DefaultFileCollectionDependency(Collections.singleton(file)); fileCollectionDependency.setScope(myScope); result.add(fileCollectionDependency); } return result; }