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).allObjects {
    sourceSets.allObjects { 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")
        }
    }
}
