CollectedResource { public static Collection<CollectedResource> fromDirectory(Path path) { Collection<CollectedResource> resources = new ArrayList<>(); try (Stream<Path> paths = Files.walk(path)) { paths.filter(Files::isRegularFile) .map(Path::toFile) .map(f -> new FileSystemResource(f) .setResourceType(determineResourceType(f.getName()))) .map(f -> new CollectedResource(path, f)) .forEach(resources::add); } catch (IOException e) { throw new UncheckedIOException(e); } return resources; } CollectedResource(Path basePath, Resource resource); static Collection<CollectedResource> fromPaths(Path... paths); static Collection<CollectedResource> fromJarFile(Path jarPath); static Collection<CollectedResource> fromDirectory(Path path); static Collection<CollectedResource> fromFiles(Path basePath, File... files); Path basePath(); Resource resource();  }
@Test void shouldNotContainDirectories() { assertThat( CollectedResource.fromDirectory(Paths.get("src/main/resources")) .stream() .map(CollectedResource::resource) .map(Resource::getSourcePath) .map(File::new) .filter(File::isDirectory) .count()).isZero(); }