Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which checkstyle version gradle is using?

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?

like image 737
duzenz Avatar asked Dec 08 '17 13:12

duzenz


People also ask

What is checkstyle in gradle?

The Checkstyle plugin performs quality checks on your project's Java source files using Checkstyle and generates reports from these checks.

How do you use a checkstyle gradle?

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.

How does gradle determine version?

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.


2 Answers

There are three ways I can think of right now, least attractive first:

  • You can look into the Gradle source code.
  • You can check the Checkstyle Compatibility Matrix (column L, yellow cells).
    Both say that from Gradle 3.3 onwards, the default Checkstyle version is 6.19; before, it was 5.9. Only Gradle versions prior to 2.4 used even older versions of Checkstyle.
  • 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.

like image 56
barfuin Avatar answered Sep 21 '22 10:09

barfuin


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
like image 44
Valerii Timofeev Avatar answered Sep 22 '22 10:09

Valerii Timofeev