apache / apache/maven-checkstyle-plugin
[MCHECKSTYLE-299] build type check goal ignored source options when using phases "test site"
- Dominant language
- Java
- Stars
- 97
- Forks
- 67
- Avg merge
- 14h 50m
- Merged PRs (30d)
- 6
Description
**[Johannes Wienke](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=languitar)** opened **[MCHECKSTYLE-299](https://issues.apache.org/jira/browse/MCHECKSTYLE-299?redirect=false)** and commented
I have a project where we enforce a zero-warnings policy. For this purpose we have included a call to `checkstyle:check` in the build phase using the following configuration:
```xml
org.apache.maven.plugins
maven-checkstyle-plugin
2.15
${project.basedir}/codecheck/checkstyle.xml
config_loc=${project.basedir}/codecheck
true
true
warning
true
${project.basedir}/src
checkstyle-validate
validate
check
```
Additionally, checkstyle is set up as a reporting goal in the reporting section:
```xml
org.apache.maven.plugins
maven-checkstyle-plugin
2.15
${project.basedir}/codecheck/checkstyle.xml
config_loc=${project.basedir}/codecheck
true
${project.basedir}/src
```
The project contains multiple source trees and some contain generated code. Therefore it is necessary to restrict checkstyle to only one of these trees where the manually maintained code lives. Otherwise, the build would fail due to warnings being detected in generated code.
This shown configuration works well when calling maven all of the following ways:
```
mvn compile
mvn test
mvn site
mvn test site
```
However, when changing the deprecated `sourceDirectory` elements to the list syntax with `sourceDirectories`, the last call `mvn test site` starts to fail and ignores the specified source directories. All previous other calls still work as expected.
When looking at the effective configuration using `mvn -X` I could see, that in the last call version with "test site", the `sourceDirectories` list of the check goal is again the complete list of source trees instead of the specified one.
Since we are also using some plugins to include the generated code etc., a reference to the complete POM might be helpful for debugging:
https://code.cor-lab.org/projects/rsb/repository/rsb-java/revisions/master/entry/pom.xml
---
**Affects:** 2.15
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the configuration with Maven using the commands listed, especially `mvn test site`, and inspect the effective configuration with `mvn -X`. Compare the `sourceDirectories` handling in the check goal against the deprecated `sourceDirectory` behavior; done means `mvn test site` checks only the configured source trees rather than all source trees.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100