-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
145 lines (125 loc) · 3.72 KB
/
build.gradle
File metadata and controls
145 lines (125 loc) · 3.72 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
def junitVersion = '4.12'
def pmdVersion = '6.18.0'
def checkstyleVersion = '7.8.1'
def findbugsVersion = '3.0.1'
def jacocoVersion = '0.8.2'
def fileConfigurationPmd = './pmdConfiguration.xml'
def fileConfigurationCheckstyle = './checkStyleConfiguration.xml'
def fileConfigurationFindBugs = './findBugsConfiguration.xml'
def nameResultDirectory = 'buildReports'
def reportFileExtension = 'report'
def excludeClasses = ['**/Demo**']
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: junitVersion
}
task buildProject(dependsOn: ['allProjectClear', 'build', 'jacocoTestReport'])
task allProjectClear {
delete file ('build')
mkdir nameResultDirectory
file(nameResultDirectory).listFiles().each { file ->
def nameFile = file.name
if (!reportFileExtension.equals(nameFile.substring(nameFile.indexOf(".") + 1))) {
delete file.getAbsolutePath()
}
}
}
pmd {
toolVersion = pmdVersion
ignoreFailures = true
sourceSets = [sourceSets.main]
ruleSetFiles file(fileConfigurationPmd)
consoleOutput = false
}
tasks.withType(Pmd) {
reports {
xml.enabled = true
xml.destination file("${nameResultDirectory}/pmdReport.xml")
html.enabled = false
}
}
checkstyle {
toolVersion checkstyleVersion
ignoreFailures = true
sourceSets = [sourceSets.main]
configFile file(fileConfigurationCheckstyle)
showViolations = false
}
tasks.withType(Checkstyle) {
reports {
xml.enabled = true
xml.destination file("${nameResultDirectory}/checkstyleReport.xml")
html.enabled = false
}
}
findbugs {
toolVersion = findbugsVersion
ignoreFailures = true
sourceSets = [sourceSets.main]
excludeFilter = file(fileConfigurationFindBugs)
}
tasks.withType(FindBugs) {
reports {
xml.enabled = true
xml.destination file("${nameResultDirectory}/findbugsReport.xml")
}
}
jacoco {
toolVersion = jacocoVersion
}
jacocoTestReport {
test {
}
reports {
xml.enabled = true
xml.destination file("${nameResultDirectory}/jacocoTestReport.xml")
csv.enabled = false
html.enabled = false
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: excludeClasses)
}) //this task is excluding the classes for coverage
}
}
ext.testsResults = [] // Container for tests summaries
allprojects { project ->
tasks.withType(Test) { testTask ->
testTask.testLogging { logging ->
events "PASSED", "FAILED", "SKIPPED", "STANDARD_ERROR", "STANDARD_OUT"
exceptionFormat 'full'
showExceptions true
showCauses true
showStackTraces true
}
ignoreFailures = true
afterSuite { desc, result ->
if (desc.parent) return
String summary = "${testTask.project.name}:${testTask.name} results: ${result.resultType} " +
"(" +
"${result.testCount} tests, " +
"${result.successfulTestCount} successes, " +
"${result.failedTestCount} failures, " +
"${result.skippedTestCount} skipped" +
")"
rootProject.testsResults += summary
}
}
}
gradle.buildFinished {
def allResults = rootProject.ext.testsResults
if (!allResults.isEmpty()) {
allResults.each{ resultTest ->
println resultTest
}
}
}