Checkstyle gradle use google checks

Viewed 603
1 Answers

The google_checks.xml is part of the published Checkstyle JAR:

checkstyle JAR contents

So you can use Gradle to retrieve the resource from the JAR.

The below will work. It is written in the Kotlin DSL, but can easily translated to the Groovy DSL.

// build.gradle.kts

plugins {
    id("java")
    id("checkstyle")
}

checkstyle {
    val archive = configurations.checkstyle.get().resolve().filter {
        it.name.startsWith("checkstyle")
    }
    config = resources.text.fromArchiveEntry(archive, "google_checks.xml")
}
Related