You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/07/23 12:30:46 UTC

[GitHub] [maven-pmd-plugin] adangel commented on a change in pull request #44: [MPMD-318] Fix the aux classpath when includeTests is set to true

adangel commented on a change in pull request #44:
URL: https://github.com/apache/maven-pmd-plugin/pull/44#discussion_r675523870



##########
File path: src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
##########
@@ -561,7 +563,7 @@ private String determineAuxClasspath() throws MavenReportException
                 }
                 TransformableFilter filter = new AndFilter( Arrays.asList(
                         new ExclusionsFilter( exclusionPatterns ),
-                        includeTests ? ScopeFilter.including( "test" ) : ScopeFilter.including( "compile" )
+                        includeTests ? ScopeFilter.including( "compile", "test" ) : ScopeFilter.including( "compile" )

Review comment:
       This looks like this is the actual fix. We probably should also consider here the scope "provided". The goal is, that we get the classpath that is used for compilation...

##########
File path: src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
##########
@@ -546,7 +548,7 @@ private String determineAuxClasspath() throws MavenReportException
     {
         try
         {
-            List<String> classpath = new ArrayList<>();
+            Set<String> classpath = new HashSet<>();

Review comment:
       This should stay a list - the order is important for the classpath

##########
File path: src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
##########
@@ -577,13 +579,19 @@ private String determineAuxClasspath() throws MavenReportException
                         dependencies.add( resolvedArtifact.getArtifact().getFile().toString() );
                     }
 
-                    List<String> projectCompileClasspath = includeTests ? localProject.getTestClasspathElements()
-                            : localProject.getCompileClasspathElements();
+                    List<String> projectClasspath = new ArrayList<>(

Review comment:
       I think, this change is not needed: `getTestClasspathElements()` contains already `getCompileClasspathElements()` - so we would have e.g. `target/classes` now twice on the classpath




-- 
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-unsubscribe@maven.apache.org

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