Specifying which Checkstyle libraries to use

How do I specify which checkstyle library to use?

The Checkstyle Plugin manual ( http://www.gradle.org/docs/current/userguide/checkstyle_plugin.html ) has an Dependency Management entry that states “checkstyle – The Checkstyle libraries to use”.

But I’m unable to figure out how to set that entry…

checkstyle {
   toolVersion = '5.6'
}

http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.quality.CheckstyleExtension.html

Aha, it seems I can specify the version like this, is that correct?

dependencies {

checkstyle ‘com.puppycrawl.tools:checkstyle:5.8-a123763’

}

I’m used to specifying plugin classpaths in the buildscript block, that’s why I was confused…

You can, but it’s only necessary if the checkstyle dependency you wish to use has coordinates other than the default “com.puppycrawl.tools:checkstyle”. Otherwise, Lance’s solution is simpler and preferable.

1 Like