You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MPMD-399] Incorrect warning: The project X does not seem to be compiled. PMD results might be inaccurate. #366
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 directory
and therefore no target/classes or target/test-classes directories are generated.
The affected code that causes the problem can be found here:
The method is deprecated, but the information is still required and needs to be obtained elsewhere. That is different discussion. I would take care of the message.
Why do you have a JAR project w/o source code in the first place?
Hold on, that confuses me. In the default case if src/main is there there should be not warning, only if src/tests are there and includeTests is false and the other way around: true and only src/main. The first case I do not understand, but the latter makes sense. You should see the warning. Can you confirm?
Forget my previous questions because localProject.getTestClasspathElements() is cumulative. Ony the documentation needs to be updated. AB-xdev, we can get back to the actual problem.
Activity
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
What packaging type is the project in question?
jira-importer commentedon Jun 10, 2024
AB-xdev commented
The packaging type is jar
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
Does it work for your with
-Dpmd.typeResolution=false?jira-importer commentedon Jun 10, 2024
AB-xdev commented
Well it then fails with some false positives (as the types are not resolved), but yes the warning is then gone.
I still prefer some incorrect warnings instead of FP, so I don't think this is a long term solution ;)
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
I am inclined to delete this entire block
maven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Lines 522 to 532 in 1961d77
maven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Lines 539 to 541 in 1961d77
Either both or none, WDYT?
jira-importer commentedon Jun 10, 2024
AB-xdev commented
Well I'm not that familiar with the code, but anyway my opinion:
Block 1: Either delete it or add some kind of flag that let's the end-user control this check
Block 2: According to https://github.com/apache/maven-pmd-plugin/blob/master/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java#L548 this seems to be deprecated anyway? Maybe a good time to remove it :)
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
The method is deprecated, but the information is still required and needs to be obtained elsewhere. That is different discussion. I would take care of the message.
Why do you have a JAR project w/o source code in the first place?
jira-importer commentedon Jun 10, 2024
AB-xdev commented
I have source code, but some modules only have it in
If either of this is the case the warning occurs
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
Hold on, that confuses me. In the default case if src/main is there there should be not warning, only if src/tests are there and
includeTestsisfalseand the other way around:trueand onlysrc/main. The first case I do not understand, but the latter makes sense. You should see the warning. Can you confirm?jira-importer commentedon Jun 10, 2024
AB-xdev commented
includeTestsis alwaystrue(set it on the parent) and produces the behavior described in https://issues.apache.org/jira/browse/MPMD-399?focusedCommentId=17853672&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17853672if I remove
includeTests(or set it tofalse) it I still get warnings for the "src/test and nothing inside src/main"-case.jira-importer commentedon Jun 10, 2024
Michael Osipov commented
I have a slight problem with
includeTests: It documentation says "Run PMD on the tests.". Looking atmaven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/AbstractPmdReport.java
Lines 351 to 384 in 1961d77
maven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Lines 516 to 518 in 1961d77
Andreas Dangel, shouldn't
auxClasspathinclude main classpath as well when tests should be included? Since dependencies are inclusive as well:maven-pmd-plugin/src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Lines 493 to 497 in 1961d77
It does not compute fo me.
AB-xdev, sorry to deviate, but that needs to clarified first.
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
I am also confused why the single project case does not include the deps...
jira-importer commentedon Jun 10, 2024
Michael Osipov commented
Forget my previous questions because
localProject.getTestClasspathElements()is cumulative. Ony the documentation needs to be updated. AB-xdev, we can get back to the actual problem.jira-importer commentedon Jun 10, 2024
Michael Osipov commented
Have a look at the PR.
jira-importer commentedon Jun 11, 2024
Andreas Dangel commented
Yes, when analyzing test code, the auxClasspath should contain both main+test dependencies.
jira-importer commentedon Jun 11, 2024
Michael Osipov commented
...and it does. I verified by debugging it. The comment for the param is just confusing.
jira-importer commentedon Jul 7, 2024
Michael Osipov commented
Fixed with 2a72cc86d5f25625059a2e7428038cb1841ac612.