elharo commented on code in PR #81:
URL:
https://github.com/apache/maven-dependency-analyzer/pull/81#discussion_r1161021500
##########
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:
I'll have to check but I don't think that will work. The method you
reference checks if a Path ends with another Path. e.g. that
/usr/local/tmp/foo.class ends with a path for foo.class. However, I don't
think it would work for /usr/local/tmp/foo.class ending with the extension
.class.
See
https://stackoverflow.com/questions/20531247/how-to-check-the-extension-of-a-java-7-path
--
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]