void (@NotNull SourceSet sourceSet, @NotNull Collection<ExternalDependency> result) { final Set<Configuration> providedConfigurations = new LinkedHashSet<>(); if (sourceSet.getName().equals("main") && myProject.getPlugins().findPlugin(WarPlugin.class) != null) { Configuration providedCompile = myProject.getConfigurations().findByName("providedCompile"); if (providedCompile != null) { providedConfigurations.add(providedCompile); } Configuration providedRuntime = myProject.getConfigurations().findByName("providedRuntime"); if (providedRuntime != null) { providedConfigurations.add(providedRuntime); } } if (providedConfigurations.isEmpty()) { return; } Multimap<Object, ExternalDependency> filesToDependenciesMap = ArrayListMultimap.create(); for (ExternalDependency dep : result) { filesToDependenciesMap.put(getFiles(dep), dep); } for (Configuration configuration : providedConfigurations) { Collection<ExternalDependency> providedDependencies = resolveDependencies(configuration, PROVIDED_SCOPE); for (Iterator<ExternalDependency> iterator = providedDependencies.iterator(); iterator.hasNext(); ) { ExternalDependency providedDependency = iterator.next(); Collection<File> files = getFiles(providedDependency); Collection<ExternalDependency> dependencies = filesToDependenciesMap.get(files); if (!dependencies.isEmpty()) { for (ExternalDependency depForScope : dependencies) { ((AbstractExternalDependency)depForScope).setScope(PROVIDED_SCOPE); } iterator.remove(); } } result.addAll(providedDependencies); } }