@Test public void testLoadFromDirectory() throws Exception { final Artifact artifact = loader.load(FilePathHelper.getPath("target/classes")); assertThat(artifact.classes()) .overridingErrorMessage("Loading classes from a directory should be supported") .isNotEmpty() .containsKey(TypeDescriptors.fromClassName(MethodDescriptor.class.getName())); }
private Artifact loadFromDirectory(ArtifactName artifactName, File dir) throws IOException { Map<ClassTypeDescriptor, DeclaredClass> classes = new HashMap<>(); List<File> classFilesInDir = Files.walk(dir.toPath()) .map(Path::toFile) .filter(file -> file.isFile() && file.getName().endsWith(".class")) .collect(toList()); for (File file : classFilesInDir) { try (FileInputStream fis = new FileInputStream(file)) { DeclaredClass cl = ClassLoader.load(fis); classes.put(cl.className(), cl); } } return artifact(artifactName, classes); }
ArtifactLoader { private Artifact loadFromDirectory(ArtifactName artifactName, File dir) throws IOException { Map<ClassTypeDescriptor, DeclaredClass> classes = new HashMap<>(); List<File> classFilesInDir = Files.walk(dir.toPath()) .map(Path::toFile) .filter(file -> file.isFile() && file.getName().endsWith(".class")) .collect(toList()); for (File file : classFilesInDir) { try (FileInputStream fis = new FileInputStream(file)) { DeclaredClass cl = ClassLoader.load(fis); classes.put(cl.className(), cl); } } return artifact(artifactName, classes); } }
ArtifactLoader { private Artifact loadFromDirectory(ArtifactName artifactName, File dir) throws IOException { Map<ClassTypeDescriptor, DeclaredClass> classes = new HashMap<>(); List<File> classFilesInDir = Files.walk(dir.toPath()) .map(Path::toFile) .filter(file -> file.isFile() && file.getName().endsWith(".class")) .collect(toList()); for (File file : classFilesInDir) { try (FileInputStream fis = new FileInputStream(file)) { DeclaredClass cl = ClassLoader.load(fis); classes.put(cl.className(), cl); } } return artifact(artifactName, classes); }  }
ArtifactLoader { private Artifact loadFromDirectory(ArtifactName artifactName, File dir) throws IOException { Map<ClassTypeDescriptor, DeclaredClass> classes = new HashMap<>(); List<File> classFilesInDir = Files.walk(dir.toPath()) .map(Path::toFile) .filter(file -> file.isFile() && file.getName().endsWith(".class")) .collect(toList()); for (File file : classFilesInDir) { try (FileInputStream fis = new FileInputStream(file)) { DeclaredClass cl = ClassLoader.load(fis); classes.put(cl.className(), cl); } } return artifact(artifactName, classes); }  Artifact load(File path); Artifact load(ArtifactName artifactName, File path); static void main(String[] args); }
ArtifactLoader { private Artifact loadFromDirectory(ArtifactName artifactName, File dir) throws IOException { Map<ClassTypeDescriptor, DeclaredClass> classes = new HashMap<>(); List<File> classFilesInDir = Files.walk(dir.toPath()) .map(Path::toFile) .filter(file -> file.isFile() && file.getName().endsWith(".class")) .collect(toList()); for (File file : classFilesInDir) { try (FileInputStream fis = new FileInputStream(file)) { DeclaredClass cl = ClassLoader.load(fis); classes.put(cl.className(), cl); } } return artifact(artifactName, classes); }  Artifact load(File path); Artifact load(ArtifactName artifactName, File path); static void main(String[] args);  }