maven-checkstyle-plugin
maven-checkstyle-plugin copied to clipboard
[MCHECKSTYLE-412] - Exclude generated sources / test-sources from defau…
…lt source / test-source directories
Following this checklist to help us incorporate your contribution quickly and easily:
- [x] Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] Format the pull request title like
[MCHECKSTYLE-XXX] - Fixes bug in ApproximateQuantiles
, where you replaceMCHECKSTYLE-XXX
with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] Run
mvn clean verify
to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] You have run the integration tests successfully (
mvn -Prun-its clean verify
).
If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement if you are unsure please ask on the developers list.
To make clear that you license your contribution under the Apache License Version 2.0, January 2004 you have to acknowledge this by using the following check-box.
-
[x] I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
-
[x] In any other case, please file an Apache Individual Contributor License Agreement.
Does the effect not will be the same as we will use for default:
project.build.sourceDirectory
project.build.testSourceDirectory
without special filtering ...
Does the effect not will be the same as we will use for default:
project.build.sourceDirectory project.build.testSourceDirectory
without special filtering ...
Not exactly.
In my team we have many projects specify the sourceDirectories
as we have JPA annotation processors and OpenAPI tools to generate REST API stubs. It is a burden we specify it now and then, so it will be perfectly that the default setting works OOB.
I had tried to change sourceDirectories
default to project.build.sourceDirectory
but it breaks https://issues.apache.org/jira/browse/MCHECKSTYLE-70 as some users use build-helper-maven-plugin to inject source directories to the build. It looks that the best solution is excluding generated sources / test-sources from the build (project.compileSourceRoots / project.testCompileSourceRoots) before sending them to checkstyle.
It will be perfect that Maven core provide some API like getGeneratedCompileSourceRoots / getGeneratedTestCompileSourceRoots
but apparently it will not go for 3.6.x and earlier versions (3.0.x, 3.3.x) . Since the generated sources / test-sources should be in build target directory we can bravely exclude the entire build target directory.
What if I want to invert this and do check generated source?
What if I want to invert this and do check generated source?
Well, this PR changes the default settings. You can still specify the sourceDirectories
and testSourceDirectories
, then checkstyle will check those directories.
Anyone want to resolve conflicts and merge? This would be useful.
Anyone want to resolve conflicts and merge? This would be useful.
I'll rebase it at this weekend.
I do not have write access to the Apache repository so I'll leave the merge to someone who's capable to do.
- Rebased onto latest master
- Added a knob
excludeGeneratedSources
to not break existing setups, it is false by default
@michael-o
Would be nice if this would have an IT showning the benefit.
Done !
@michael-o
Would be nice if this would have an IT showning the benefit.
Done !
Testing...
Thanks!