/
build.gradle.kts
95 lines (85 loc) · 2.34 KB
/
build.gradle.kts
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
// tag::apply-plugin[]
plugins {
// end::apply-plugin[]
java
// tag::apply-plugin[]
jacoco
}
// end::apply-plugin[]
// tag::jacoco-configuration[]
jacoco {
toolVersion = "0.8.11"
reportsDirectory = layout.buildDirectory.dir("customJacocoReportDir")
}
// end::jacoco-configuration[]
repositories {
mavenCentral()
}
dependencies {
testImplementation("junit:junit:4.+")
}
// tag::testtask-configuration[]
tasks.test {
extensions.configure(JacocoTaskExtension::class) {
destinationFile = layout.buildDirectory.file("jacoco/jacocoTest.exec").get().asFile
classDumpDir = layout.buildDirectory.dir("jacoco/classpathdumps").get().asFile
}
}
// end::testtask-configuration[]
// tag::testtask-dependency[]
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}
// end::testtask-dependency[]
// tag::report-configuration[]
tasks.jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}
// end::report-configuration[]
// tag::violation-rules-configuration[]
tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = "0.5".toBigDecimal()
}
}
rule {
isEnabled = false
element = "CLASS"
includes = listOf("org.gradle.*")
limit {
counter = "LINE"
value = "TOTALCOUNT"
maximum = "0.3".toBigDecimal()
}
}
}
}
// end::violation-rules-configuration[]
// tag::testtask-configuration-defaults[]
tasks.test {
configure<JacocoTaskExtension> {
isEnabled = true
destinationFile = layout.buildDirectory.file("jacoco/${name}.exec").get().asFile
includes = emptyList()
excludes = emptyList()
excludeClassLoaders = emptyList()
isIncludeNoLocationClasses = false
sessionId = "<auto-generated value>"
isDumpOnExit = true
classDumpDir = null
output = JacocoTaskExtension.Output.FILE
address = "localhost"
port = 6300
isJmx = false
}
}
// end::testtask-configuration-defaults[]