-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
112 lines (96 loc) · 3.39 KB
/
build.gradle
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'java'
apply plugin: 'idea'
allprojects {
apply plugin: 'jacoco'
}
repositories {
mavenCentral()
}
dependencies {
compile 'net.sourceforge.pmd:pmd:5.3.0'
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.11'
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
options.compilerArgs << "-Werror"
}
test {
setMaxParallelForks Runtime.runtime.availableProcessors()
afterTest { desc, result ->
String suiteName = desc.className.substring(desc.className.lastIndexOf('.') + 1)
println "[${suiteName}]: ${result.resultType} in ${desc.name}"
}
}
checkstyle {
toolVersion = '7.2'
checkstyleMain.configFile = new File(rootDir.getAbsolutePath() + "/.config/checkstyle/", "main.xml")
checkstyleTest.configFile = new File(rootDir.getAbsolutePath() + "/.config/checkstyle/", "test.xml")
}
pmd {
pmdMain.ruleSetFiles = files(rootDir.getAbsolutePath() + "/.config/pmd/rules.xml")
pmdTest.ruleSets = [ "java-basic", "java-braces" ]
}
gradle.taskGraph.beforeTask { Task task ->
if (task.name == 'jfxDeploy') {
task.enabled = false
}
}
gradle.taskGraph.afterTask { Task task, TaskState state ->
if ((task.name == 'pmdMain' || task.name == 'pmdTest') && state.failure) {
def outFile = task.name == 'pmdMain' ? 'main.xml' : 'test.xml'
def reportFile = file("${buildDir}/reports/pmd/${outFile}")
if (reportFile.exists()) {
def result = new XmlParser().parse(reportFile)
result.file.each { file ->
file.violation.each { violation ->
println "${file.'@name'}:${violation.'@beginline'}: ${violation.text()}"
}
}
reportFile.delete()
}
} else if (task.name == 'jacocoTestReport'
&& state.getExecuted() && state.getSkipped()
&& task.getProject().getName() != 'agile-course-practice') {
println '[**************** \\(°□°)/ ****************]'
throw new RuntimeException("Cannot proceed w/o test report!")
} else if (task.name == 'jacocoRootReport' && state.failure) {
println '[**************** \\(°□°)/ ****************]'
throw new RuntimeException("Cannot proceed w/o test report!")
}
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
}
}
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
sourceDirectories = files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
reports {
html.enabled = true
xml.enabled = true
csv.enabled = false
xml.destination = "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}