Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle checkstyle just output warn, but build sucess

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

like image 721
sssvip Avatar asked Dec 30 '16 10:12

sssvip


People also ask

How do I run checkstyle in gradle?

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.

How do I disable checkstyle in gradle?

Also you can use '-x checkstyleTest' to exclude the task via command line.


1 Answers

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.

like image 192
xxSwordy Avatar answered Oct 22 '22 20:10

xxSwordy