Checkstyle plugin not compatible with checkstyle version > 6.9

Im using Gradle 2.10 and I’m trying to use he checkstyle plugin with the lastest version of checkstyle which is 6.14.1

I get this message:
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:checkstyleMain’.

Unable to create a Checker: configLocation {C:\Users\kec\workspace\XcodeCon3\CAGenEGL2JS\checkstyle.xml}, classpath {C:\Users\kec\workspace\XcodeCon
3\CAGenEGL2JS\build\classes\main;C:\Users\kec\workspace\XcodeCon3\CAGenEGL2JS\build\resources\main}.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.79 secs

buid.gradle
apply plugin: ‘java’
apply plugin: ‘checkstyle’

sourceCompatibility = 1.7
targetCompatibility = 1.7

repositories {
    mavenCentral()
}

dependencies {
    checkstyle 'com.puppycrawl.tools:checkstyle:6.14.1'
}

sourceSets {
    main {
        java.srcDirs = ['src']
    }
}

checkstyle {
   configFile = new File(rootDir, "checkstyle.xml")
}

checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">


<module name="EmptyForInitializerPad">
    <property name="option" value="nospace"/>
</module>

I think you should configure the tool version rather than the dependencies

Eg

apply plugin: 'java'
apply plugin: 'checkstyle'

sourceCompatibility = 1.7
targetCompatibility = 1.7

repositories {
    mavenCentral()
}

sourceSets {
    main {
        java.srcDirs = ['src']
    }
}

checkstyle {
   configFile = new File(rootDir, "checkstyle.xml")
   toolVersion ="6.14.1" 
}

Thanks, but it does not change anything. The error is the same.

Where does toolVersion come from? I can’t find it in the documentation.

Here’s the docs https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.CheckstyleExtension.html

This isn’t a compatibility issue between checkstyle and the plugin. The checkstyle.xml file is just invalid.

EmptyForInitializerPad is a child module of TreeWalker and everything requires a root Checker module. You can’t just throw the EmptyForInitializerPad module out there without anything else.

Review the checkstyle documentation for information and examples on how to create a correct checkstyle.xml: http://checkstyle.sourceforge.net/config.html.

Yes your are right. This is a much better checkstyle.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="EmptyForInitializerPad">
            <property name="option" value="nospace"/>
        </module>
    </module>
</module>

Thanks a lot.