adangel commented on code in PR #154:
URL: https://github.com/apache/maven-pmd-plugin/pull/154#discussion_r1635338206


##########
src/main/java/org/apache/maven/plugins/pmd/PmdReport.java:
##########
@@ -513,23 +513,11 @@ private String determineAuxClasspath() throws 
MavenReportException {
                                 
resolvedArtifact.getArtifact().getFile().toString());
                     }
 
-                    List<String> projectClasspath = includeTests
-                            ? localProject.getTestClasspathElements()
-                            : localProject.getCompileClasspathElements();
-
-                    // Add the project's target folder first
-                    classpath.addAll(projectClasspath);
-                    if (!localProject.isExecutionRoot()) {
-                        for (String path : projectClasspath) {
-                            File pathFile = new File(path);
-                            String[] children = pathFile.list();
-
-                            if (!pathFile.exists() || (children != null && 
children.length == 0)) {
-                                getLog().warn("The project " + 
localProject.getArtifactId()
-                                        + " does not seem to be compiled. PMD 
results might be inaccurate.");

Review Comment:
   I don't know if that's possible without breaking anything... I _think_ it 
has to do, that the goal `pmd` is also a reporting mojo (that was probably the 
very first feature) as well as creating the pmd.xml file with the report, that 
is used by the goal `verify` to maybe fail the build (`verify` forks `pmd`) 
(and this feature was probably added on top just reusing the reporting 
mojo...). Not sure how other plugins deal with this (e.g. checkstyle, spotbugs, 
...). What I've seen is, that m-pmd-p tries to avoid being called multiple 
times (which makes sense, it needs to run only once; see the 
`canGenerateReport` method which actually executes PMD, and `executeReport` 
only renders the result).
   
   If we would add the fork to `compile` or `test-compile`, would the compile 
phase be called multiple times? e.g. mvn verify -> compile -> pmd:check >> 
pmd:pmd >> compile?
   
   For the concrete issue MPMD-399, I would either remove the warning message 
(and ignore this whole discussion: if m-pmd-p is used correctly, there are no 
problems). Or try to improve the logic, when we issue the warning (we can 
easily fix the target/classes and/or target/test-classes is missing/empty - but 
there might be other cases. Maybe there is a different way to figure out, if 
the project has been compiled already).
   



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