as you can see the checkstyle warn,but the build of this time is still success. why? I want it faild. please help.
D:\MyData\xxxx>gradle clean checkstyleMain
:clean
:compileJava
:processResources
:classes
:checkstyleMain
[ant:checkstyle] [WARN] D:\MyData\xxxx.java:218:18: Member name 'Aource'
must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [MemberName]
BUILD SUCCESSFUL
Total time: 4.966 secs
```
see the img: https://i.stack.imgur.com/7IbRM.jpg
see the checkstyle.xml: https://i.stack.imgur.com/BE4An.jpg
To use checkstyle in Gradle you have add the plug-in to your build. gradle and provide a config\checkstyle\checkstyle. xml checkstyle configuration file. A detailed example is given in the checkstyle with Gradle exercise.
Also you can use '-x checkstyleTest' to exclude the task via command line.
Sorry for grave-digging but I just stumbled across this while trying to achieve the same thing. Turns out that this has now been implemented, but requires a tiny configuration change.
So for any future adventures finding their way here: in your build.gradle
to the following:
checkstyle {
ignoreFailures = false
maxWarnings = 0
}
This will then cause your builds to fail on Checkstyle errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With