slawekjaranowski commented on a change in pull request #52:
URL: 
https://github.com/apache/maven-dependency-analyzer/pull/52#discussion_r812040338



##########
File path: 
src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzer.java
##########
@@ -201,48 +206,26 @@ else if ( file != null && file.isDirectory() )
         return artifactClassMap;
     }
 
-    private Set<String> buildTestDependencyClasses( MavenProject project ) 
throws IOException
+    private Set<String> buildTestOnlyDependencyClasses( Set<String> 
mainDependencyClasses,
+                                                        Set<String> 
testDependencyClasses )
     {
-        Set<String> testOnlyDependencyClasses = new HashSet<>();
-
-        String outputDirectory = project.getBuild().getOutputDirectory();
-        Set<String> nonTestDependencyClasses = new HashSet<>( 
buildDependencyClasses( outputDirectory ) );
-
-        String testOutputDirectory = 
project.getBuild().getTestOutputDirectory();
-        Set<String> testDependencyClasses = new HashSet<>( 
buildDependencyClasses( testOutputDirectory ) );
-
-        for ( String testString : testDependencyClasses )
-        {
-            if ( !nonTestDependencyClasses.contains( testString ) )
-            {
-                testOnlyDependencyClasses.add( testString );
-            }
-        }
-
-        return testOnlyDependencyClasses;
+        return testDependencyClasses.stream()
+            .filter( klass -> !mainDependencyClasses.contains( klass ) )

Review comment:
       use `Set.removeAll`




-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to