apply plugin: 'code-quality'

def configDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config')

checkstyleConfigDir = "$configDir/checkstyle"
checkstyleConfigFileName = new File(checkstyleConfigDir, "checkstyle.xml")
codeNarcConfigFileName = "$configDir/codenarc.xml"
checkstyleProperties.checkstyleConfigDir = checkstyleConfigDir

plugins.withType(GroovyBasePlugin) {
    sourceSets.all { sourceSet ->
        task "${sourceSet.getTaskName('checkstyle', 'groovy')}"(type: Checkstyle) {
            configFile = new File(checkstyleConfigDir, "checkstyle-groovy.xml")
            source sourceSet.allGroovy
            classpath = sourceSet.compileClasspath
            resultFile = new File(checkstyleResultsDir, "${sourceSet.name}-groovy.xml")
        }
    }
}
