File: codeQuality.gradle

package info (click to toggle)
gradle 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 85,104 kB
  • sloc: java: 319,724; xml: 14,356; cpp: 4,200; ansic: 1,025; sh: 300; makefile: 60; asm: 17; jsp: 17; objc: 10
file content (55 lines) | stat: -rw-r--r-- 1,737 bytes parent folder | download | duplicates (4)
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
}