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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
apply plugin: 'checkstyle'
apply plugin: 'codenarc'
def validateTaskPropertiesForConfiguration(Configuration configuration) {
// Apply to all projects depending on :core
configuration.dependencies.withType(ProjectDependency).matching { it.dependencyProject == project(":core") }.all {
project.apply from: "$rootDir/gradle/taskProperties.gradle"
}
}
plugins.withType(JavaBasePlugin) {
validateTaskPropertiesForConfiguration(configurations.compile)
}
plugins.withType(JavaLibraryPlugin) {
validateTaskPropertiesForConfiguration(configurations.api)
}
def codeQualityConfigDir = new File(buildscript.sourceFile.parentFile.parentFile, 'config')
codenarc {
configFile = new File(codeQualityConfigDir, "codenarc.xml")
}
checkstyle {
configDir = new File(codeQualityConfigDir, "checkstyle")
}
tasks.withType(CodeNarc) {
reports.xml.enabled = true
}
configurations.codenarc.resolutionStrategy.force(libraries.groovy)
plugins.withType(GroovyBasePlugin) {
sourceSets.all { sourceSet ->
task "${sourceSet.getTaskName('checkstyle', 'groovy')}"(type: Checkstyle) {
configFile = new File(checkstyle.configDir, "checkstyle-groovy.xml")
source sourceSet.allGroovy
classpath = sourceSet.compileClasspath
reports.xml.destination new File(checkstyle.reportsDir, "${sourceSet.name}-groovy.xml")
}
}
}
def codeQualityTasks = tasks.matching { task ->
[org.gradle.api.plugins.quality.CodeNarc, org.gradle.api.plugins.quality.Checkstyle, org.gradle.plugin.devel.tasks.ValidateTaskProperties].any { it.isInstance(task) }
}
task codeQuality {
dependsOn codeQualityTasks
}
tasks.withType(Test) {
shouldRunAfter codeQualityTasks
}
|