[java] Fix #5746: Separate test sources and resources#6619
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 1 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes. Give us feedback
|
No relevant source code has been changed, pmdtester skipped. (comment created at 2026-05-10 12:42:18+00:00 for da69544) |
These suppressions weren't needed before the move, they aren't needed after the move.
5bdd468 to
e51c810
Compare
|
Thanks for continuing this work.
This is about the configuration of the maven-pmd-plugin: Lines 550 to 607 in 941fc0f By default, m-pmd-p will use all compile source roots (see https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html#compileSourceRoots) and test source roots ( https://maven.apache.org/plugins/maven-pmd-plugin/pmd-mojo.html#testSourceRoots ). Now, for the "pmd-test" execution: (Btw - we use different executions to have different rulesets for the tests classes) We now need to make sure, that we only analyze src/test/java and not src/test/java-resources . We might need to set includeTests=false - as otherwise all the test roots you added with build-helper-maven-plugin would be analyzed. I think, we added src/test/java as compileSourceRoot and not as testSourceRoot because m-pmd-p doesn't support to run on only on tests - it only support main or main+test combinations. So, we sell in the "pmd-test" execution main for test... Since we are introducing "src/test/java-resources" now only for the pmd-java module and not for the others, we should probably leave the config in the parent-pom as is and adjust the config for pmd-java only: Lines 130 to 135 in e7d8c88 The problem, we want to solve with all this is: Can we now enable UnusedPrivateMethod in https://github.com/pmd/build-tools/blob/main/src/main/resources/net/sourceforge/pmd/pmd-test-dogfood-config.xml ? Did you try this? Does it work? There are some other tasks on the original PRs:
Do we want to run checkstyle against src/test/java-resources? |
The pmd-test config in the parent pom already defines src/test/java as a regular (non-test) source. Setting includeTests to false excludes the new src/test/java-resources directory.
|
I read somewhere that checkstyle is used to verify the license header. That part applies to src/test/java-resources as well. Apart from that, I believe I have addressed all your comments. I tested with a locally installed version of build-tools, where I added <rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
<priority>1</priority>
</rule>to pmd-test-dogfood-config. The build is green, and if I add a unused private method to one of the tests, the build turns red. |
|
Thank you @UncleOwen and @adangel for bringing this to the finish line 🎉 |
Describe the PR
I rebased and updated @oowekyala's PR for #5746. All of the credits go to @oowekyala. This should enable us to add UnusedPrivateMethod (and possibly others) to https://github.com/pmd/build-tools/blob/main/src/main/resources/net/sourceforge/pmd/pmd-test-dogfood-config.xml.
I don't understand what is meant by "Update pom.xml to exclude generated-sources/... etc also for "pmd-test" execution (excludeRoots)" in the original PR. Could someone enlighten me?
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)