Gradle Failed to start checkstyle

I have a java project on my laptop and I am building it with gradle. All dependencies are in the file system, since I work on it most of the time. In any case, there are not so many of them.

build.gradle:

repositories {
    flatDir {
        dirs "${rootDir}/lib/main", "${rootDir}/lib/test", "${rootDir}/lib/quality"
    }
}

ext.configDir = "${rootDir}/gradle/config"
ext.scriptsDir = "${rootDir}/gradle/scripts"

Now I need to add some quality checks to my code. I was fortunate enough to get PMD to test work, but not so lucky with checkstyle. An example from the gradle distribution, the gradle in the action book I read, the gradle documentation doesn't seem to be rocket science, but I just can't get it to work, which becomes very annoying, especially with ant, that would be five minutes. Anyway, this is my gradle.build entry for checkstyle:

apply from: "${scriptsDir}/checkstyle.gradle"

checkstyle.gradle ( ):

apply plugin: 'checkstyle'

ext.checkstyleConfigDir = new File(configDir, "checkstyle")
ext.checkstyleReportsDir = new File(reportsDir, "checkstyle")
ext.xslStyleFile = new File(checkstyleConfigDir, "checkstyle-noframes.xsl")

checkstyle {
    toolVersion = '6.10.1'
    configFile = new File(checkstyleConfigDir, 'sun_checks.xml')
    ignoreFailures = true
    showViolations = true
}

checkstyleMain.doLast {
    def main = new File(checkstyleReportsDir, "main.xml")
    if (main.exists()) {
        ant.xslt(in: main, style: xslStyleFile, out: new File(checkstyleReportsDir, "main.html"))
    }
}

dependencies {
    checkstyle( 'com.puppycrawl.tools:checkstyle:6.10.1' )
}

checkstyle , :

* What went wrong:
Execution failed for task ':checkstyleMain'.
> java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.CheckStyleTask

checkstyle-6.10.1.jar, , , com.puppycrawl.tools.checkstyle.CheckStyleTask, , com.puppycrawl.tools.checkstyle.ant.CheckStyleAntTask, , , gradle. , gradle .

, , , toolVersion = '6.10.1' , gradle . gradle api : "String toolVersion ."

.

.

+4
1

Gradle (GRADLE-3314). ​​ Gradle 2.7, . , 2.7?

Gradle 2.7-rc-2 gradle .

+4

Source: https://habr.com/ru/post/1606310/


All Articles