In my gradle file I have:
apply plugin: 'checkstyle'
I'm trying to create my own checkstyle rules. For this reason I have added a dependency to my gradle file.
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:8.2'
}
I am trying to extend "Check" class of checkstyle. But there are a lot of version of checkstyle and I dont know which one is used by gradle.
How can I find the exact version number of checkstyle which gradle is using?
The Checkstyle plugin performs quality checks on your project's Java source files using Checkstyle and generates reports from these checks.
2.1. 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.
If you are using the Gradle wrapper, then your project will have a gradle/wrapper/gradle-wrapper. properties folder. This determines which version of Gradle you are using.
There are three ways I can think of right now, least attractive first:
But the recommended way is to choose the Checkstyle version explicitly, by specifying it in your build.gradle file:
checkstyle {
configFile file('your/checkstyle.xml');
toolVersion '8.2'; // your choice here
}
This is better than relying on the default version, because you can use much newer versions of Checkstyle, and your Checkstyle setup won't break when you update Gradle.
You can check the current value of checkstyle.toolVersion
by writing this in your build.gradle file and reloading your gradle project
plugins {
id 'java'
id 'checkstyle'
}
println checkstyle.toolVersion
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