Collection<ExternalDependency> ( @NotNull final SourceSet sourceSet, @NotNull final Map<File, Integer> classpathOrder, @Nullable final String scope) { @NotNull final Collection<ExternalDependency> result = new LinkedHashSet<>(); Set<File> runtimeOutputDirs = sourceSet.getOutput().getDirs().getFiles(); for (File dir : runtimeOutputDirs) { DefaultFileCollectionDependency runtimeOutputDirsDependency = new DefaultFileCollectionDependency(Collections.singleton(dir)); runtimeOutputDirsDependency.setScope(scope); Integer fileOrder = classpathOrder.get(dir); runtimeOutputDirsDependency.setClasspathOrder(fileOrder != null ? fileOrder : -1); result.add(runtimeOutputDirsDependency); } return result; }