Android Studio checkstyle task

2019-04-15 12:13发布

I have an project (multi-module) in which I use checkstyle task. This is the relevant configuration:

apply plugin: 'checkstyle'
check.dependsOn 'checkstyle'

// Set the directory for quality config files
def configDir = "${project.rootDir}/quality_tools"
// Set the directory for quality reports
def reportsDir = "${project.buildDir}/reports"

checkstyle {
    toolVersion = "7.6"

    configFile file("$configDir/checkstyle/google_checks.xml")
    configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
}

@ParallelizableTask
class ParallelCheckstyle extends Checkstyle {}

task checkstyle(type: ParallelCheckstyle, group: 'verification') {
    description 'Runs Checkstyle inspection against Android sourcesets.'

    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    exclude '**/test/**'
    exclude '**/androidTest/**'
    exclude '**/R.java'
    exclude '**/BuildConfig.java'

    classpath = files()
}

This gives me the following error:

Execution failed for task ':domain:checkstyle'. Unable to create Root Module: configLocation {[my_project_path]\quality_tools\checkstyle\google_checks.xml}, classpath {null}.

If I downgrade the tool version to 7.4 it seems to work fine. Is there a way to make it work with the latest version, or can anyone let me know if I did something wrong in the configuration?

Thank you.

1条回答
放我归山
2楼-- · 2019-04-15 12:34

It seems the checkstyle task fails because of the properties of the config file. I've updated to the latest version of google_checks.xm and it works fine now.

The error description was missleading.

查看更多
登录 后发表回答