Set<File> (@Nullable ExternalProject externalProject) { if (externalProject == null) { return Collections.emptySet(); } return externalProject.getSourceSets().values().stream() .flatMap(ss -> ss.getSources().entrySet().stream() .filter(e -> !e.getKey().isResource()) .flatMap(e -> e.getValue().getSrcDirs().stream())) .collect(Collectors.toCollection(() -> FileCollectionFactory.createCanonicalFileSet())); }