Checkstyle Plugin does not add gradle tasks

Viewed 5099

i want to use checkstyle plugin in my gradle project, the gradle documentation says that it will add a few tasks: https://docs.gradle.org/current/userguide/checkstyle_plugin.html

checkstyleMain, checkstyleTest, checkstyleSourceSet

I added this into my app build.gradle file:

apply plugin: 'checkstyle'

I want to run gradle task from cmd to perform code style check, but there are no one checkstyle task. I checked the whole list by typing:

./gradlew tasks

I also tried to add checkstyle jar as library dependency to app module. Can anyone tell me what i am doing wrong and how can i get my checkstyle tasks?

3 Answers

You also need a checkstyle configuration file, either by placing one at the default location as documented or by configuring it explicitly.

For example:

checkstyle {
  config = resources.text.fromFile('config/checkstyle.xml')
}
Related