Gradle build files (*.gradle) are Groovy, so I'd like to perform code style checks on the build files, as with any other code in the project. So I figured CodeNarc would work for this.
The minimum to get CodeNarc itself hooked into Gradle appears to be the following:
apply plugin: 'groovy'
apply plugin: 'codenarc'
dependencies {
codenarc 'org.codenarc:CodeNarc:1.1'
}
tasks.withType(CodeNarc) {
// contents of the config file are not interesting enough to list
configFile = rootProject.file('config/codenarc/codenarc.groovy')
}
When I run this, it does nothing, because we don't have any groovy main or test files. That's fine, we never intend to use Groovy in the project itself.
But what I'm wondering is, how we can point this thing at the Gradle build files themselves?