elharo commented on code in PR #81:
URL: 
https://github.com/apache/maven-dependency-analyzer/pull/81#discussion_r1141350483


##########
src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtils.java:
##########
@@ -108,41 +106,30 @@ private static void acceptJar( URL url, ClassFileVisitor 
visitor )
     private static void acceptDirectory( File directory, ClassFileVisitor 
visitor )
         throws IOException
     {
-        if ( !directory.isDirectory() )
+    
+        List<Path> classFiles = Files.walk( directory.toPath() )
+            .filter( path -> path.toFile().getName().endsWith( ".class" ) )
+            .collect( Collectors.toList() );
+            
+        for ( Path path : classFiles )
         {
-            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 );
-
-            try ( InputStream in = new FileInputStream( file ) )
+            try ( InputStream in = Files.newInputStream( path ) )
             {
-                visitClass( path, in, visitor );
+                visitClass( directory, path, in, visitor );
             }
         }
     }
 
-    private static void visitClass( String path, InputStream in, 
ClassFileVisitor visitor )
+    private static void visitClass( File baseDirectory, Path path, InputStream 
in, ClassFileVisitor visitor )
     {
-        if ( !path.endsWith( ".class" ) )
-        {
-            throw new IllegalArgumentException( "Path is not a class" );
-        }
+        // getPath() returns a String, not a java.nio.file.Path
+        String stringPath = path.toFile().getPath().substring( 
baseDirectory.getPath().length() + 1 );

Review Comment:
   Done



-- 
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]

Reply via email to