michael-o commented on code in PR #81:
URL:
https://github.com/apache/maven-dependency-analyzer/pull/81#discussion_r1161016212
##########
src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtils.java:
##########
@@ -77,45 +77,39 @@ private static void acceptJar(URL url, ClassFileVisitor
visitor) throws IOExcept
String name = entry.getName();
// ignore files like package-info.class and module-info.class
if (name.endsWith(".class") && name.indexOf('-') == -1) {
- visitClass(name, in, visitor);
+ // Jars(ZIP) always use / as the separator character
+ visitClass(name, in, visitor, '/');
}
}
}
}
private static void acceptDirectory(File directory, ClassFileVisitor
visitor) throws IOException {
- if (!directory.isDirectory()) {
- throw new IllegalArgumentException("File is not a directory");
- }
-
- DirectoryScanner scanner = new DirectoryScanner();
-
- scanner.setBasedir(directory);
- scanner.setIncludes(new String[] {"**/*.class"});
-
- scanner.scan();
- String[] paths = scanner.getIncludedFiles();
-
- for (String path : paths) {
- path = path.replace(File.separatorChar, '/');
-
- File file = new File(directory, path);
+ List<Path> classFiles;
+ try (Stream<Path> walk = Files.walk(directory.toPath())) {
+ classFiles = walk.filter(path ->
path.getFileName().toString().endsWith(".class"))
Review Comment:
There is a native `endsWith()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]