void (@NotNull SourceSet sourceSet, @NotNull Collection<ExternalDependency> result) { Multimap<Object, ExternalDependency> filesToDependenciesMap;// handle provided dependencies final Set<Configuration> providedConfigurations = new LinkedHashSet<>(); filesToDependenciesMap = ArrayListMultimap.create(); for (ExternalDependency dep : new DependencyTraverser(result)) { filesToDependenciesMap.put(getFiles(dep), dep); } if (sourceSet.getName().equals("main") && myProject.getPlugins().findPlugin(WarPlugin.class) != null) { providedConfigurations.add(myProject.getConfigurations().findByName("providedCompile")); providedConfigurations.add(myProject.getConfigurations().findByName("providedRuntime")); } final IdeaPlugin ideaPlugin = myProject.getPlugins().findPlugin(IdeaPlugin.class); if (ideaPlugin != null) { Map<String, Map<String, Collection<Configuration>>> scopes = ideaPlugin.getModel().getModule().getScopes(); Map<String, Collection<Configuration>> providedPlusScopes = scopes.get(PROVIDED_SCOPE); if (providedPlusScopes != null && providedPlusScopes.get("plus") != null) { Iterable<Configuration> ideaPluginProvidedConfigurations = filter(providedPlusScopes.get("plus"), new MyPredicate<Configuration>() { @Override public boolean apply(Configuration cfg) { // filter default 'compileClasspath' for slight optimization since it has been already processed as compile dependencies return !cfg.getName().equals("compileClasspath") // since gradle 3.4 'idea' plugin PROVIDED scope.plus contains 'providedCompile' and 'providedRuntime' configurations // see https://github.com/gradle/gradle/commit/c46897ae840c5ebb32946009c83d861ee194ab96#diff-0fa13ec419e839ef2d355b7feb88b815R432 && !providedConfigurations.contains(cfg); } }); for (Configuration configuration : ideaPluginProvidedConfigurations) { Collection<ExternalDependency> providedDependencies = resolveDependencies(configuration, PROVIDED_SCOPE).getExternalDeps(); for(ExternalDependency it : new DependencyTraverser(providedDependencies)) { filesToDependenciesMap.put(getFiles(it), it); } result.addAll(providedDependencies); } } } for (Configuration cfg : providedConfigurations) { Collection<ExternalDependency> providedDependencies = resolveDependencies(cfg, PROVIDED_SCOPE).getExternalDeps(); for (ExternalDependency dep : new DependencyTraverser(providedDependencies)) { Collection<ExternalDependency> dependencies = filesToDependenciesMap.get(getFiles(dep)); if (!dependencies.isEmpty()) { if (dep.getDependencies().isEmpty()) { providedDependencies.remove(dep); } for (ExternalDependency depForScope: dependencies) { ((AbstractExternalDependency)depForScope).setScope(PROVIDED_SCOPE); } } else { filesToDependenciesMap.put(getFiles(dep), dep); } } result.addAll(providedDependencies); } }