1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
apply plugin: 'checkstyle'
apply plugin: 'codenarc'
def configDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config')
ext.checkstyleConfigDir = "$configDir/checkstyle"
checkstyle {
configFile = new File(checkstyleConfigDir, "checkstyle.xml")
configProperties.checkstyleConfigDir = checkstyleConfigDir
}
codenarc {
configFile = new File(configDir, "codenarc.xml")
}
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
reports.xml.destination new File(checkstyle.reportsDir, "${sourceSet.name}-groovy.xml")
}
}
}
task codeQuality {
dependsOn tasks.matching { task ->
[org.gradle.api.plugins.quality.CodeNarc, org.gradle.api.plugins.quality.Checkstyle].any { it.isInstance(task) }
}
}
|