[ https://issues.apache.org/jira/browse/MPMD-399?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17854167#comment-17854167 ]
ASF GitHub Bot commented on MPMD-399: ------------------------------------- michael-o commented on code in PR #154: URL: https://github.com/apache/maven-pmd-plugin/pull/154#discussion_r1635351234 ########## 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 doubt that the goals can be made right without breaking something. We also should split report and validation goals. We should move this to a separate dicussion. Too broad for now. > 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? Could be the case w/o an analysis. > For the concrete issue [MPMD-399](https://issues.apache.org/jira/browse/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). One the problems, as layed out in MPMD-399, is that if the param is set in the parent and not all plugins have either/proper combo there will be always a warning. For now, I would not put too much logic into it. You know PMD best. If you think that the warning should stay as a safe guard I am fine with that. I trust you, if you think that the confusion is not worth the warning, we should remove mit. ########## 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 doubt that the goals can be made right without breaking something. We also should split report and validation goals. We should move this to a separate dicussion. Too broad for now. > 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? Could be the case w/o an analysis. > For the concrete issue [MPMD-399](https://issues.apache.org/jira/browse/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). One the problems, as layed out in MPMD-399, is that if the param is set in the parent and not all plugins have either/proper combo there will be always a warning. For now, I would not put too much logic into it. You know PMD best. If you think that the warning should stay as a safe guard I am fine with that. I trust you, if you think that the confusion is not worth the warning, we should remove it. > Incorrect warning: The project X does not seem to be compiled. PMD results > might be inaccurate. > ----------------------------------------------------------------------------------------------- > > Key: MPMD-399 > URL: https://issues.apache.org/jira/browse/MPMD-399 > Project: Maven PMD Plugin > Issue Type: Bug > Components: PMD > Affects Versions: 3.22.0 > Reporter: AB-xdev > Priority: Major > > PMD plugin is reporting the following warnings on in a multi-maven project: > "The project X does not seem to be compiled. PMD results might be inaccurate." > This is caused by the fact that not all modules have a > * {{src/main/java}} or > * {{src/test/java}} folder > and therefore no {{target/classes}} or {{target/test-classes}} folders are > generated. > The affected code that causes the problem can be found here: > [https://github.com/apache/maven-pmd-plugin/blob/1961d771ea585e9344c25dfde194ee64a1b9040b/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java#L516-L532] > h3. Reproduction example > * Create a maven multi-module project > * Leave {{src/main/java}} of one module empty > * Execute {{pmd:aggregate-pmd}} or {{test pmd:aggregate-pmd-no-fork > -DskipTests}} > → (x) Warning is reported > h3. Possible fixes > * Make it possible to ignore this warning > * Do not warn when at least {{target/classes}} or {{target/test-classes}} is > present > -- This message was sent by Atlassian Jira (v8.20.10#820010)