Collection<FileCollectionDependency> (@NotNull Set<String> resolvedFiles, @NotNull Configuration configuration, @Nullable String scope) { ArtifactView artifactView = configuration.getIncoming().artifactView(new Action<ArtifactView.ViewConfiguration>() { @Override public void execute(@SuppressWarnings("NullableProblems") ArtifactView.ViewConfiguration configuration) { configuration.setLenient(true); configuration.componentFilter(new Spec<ComponentIdentifier>() { @Override public boolean isSatisfiedBy(ComponentIdentifier identifier) { return !(identifier instanceof ProjectComponentIdentifier || identifier instanceof ModuleComponentIdentifier); } }); } }); Set<ResolvedArtifactResult> artifactResults = artifactView.getArtifacts().getArtifacts(); Collection<FileCollectionDependency> result = new LinkedHashSet<>(); for (ResolvedArtifactResult artifactResult : artifactResults) { File file = artifactResult.getFile(); if (!resolvedFiles.contains(file.getPath())) { DefaultFileCollectionDependency fileCollectionDependency = new DefaultFileCollectionDependency(singleton(file)); fileCollectionDependency.setScope(scope); result.add(fileCollectionDependency); } } return result; }