forked from myeongjae-kim/learning-fp-in-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.gradle.kts
88 lines (72 loc) · 2.13 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
plugins {
jacoco
id(Libs.Plugins.kotlinJvm) version Libs.Versions.kotlin
id(Libs.Plugins.ktlint) version Libs.Versions.ktlint
id(Libs.Plugins.ktlintIdea) version Libs.Versions.ktlint
id(Libs.Plugins.jacocoBadge) version Libs.Versions.jacocoBadge
}
group = "org.kiworkshop.learningfpinkotlin"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib", Libs.Versions.kotlin))
testImplementation(Libs.Test.kotest)
testImplementation(Libs.Test.kotestAssertionsCore)
testImplementation(Libs.Test.kotestPropertyTesting)
testImplementation(Libs.Test.mockk)
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.ktlintFormat.get().group = "verification"
tasks.ktlintCheck.get().group = "other"
tasks.check {
dependsOn(tasks.ktlintFormat)
}
configure<JacocoPluginExtension> {
toolVersion = Libs.Versions.jacoco
}
tasks.withType<JacocoReport> {
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(true)
}
}
tasks.withType<JacocoCoverageVerification> {
violationRules {
rule {
element = "BUNDLE"
limit {
counter = "BRANCH"
value = "COVEREDRATIO"
minimum = "0.0".toBigDecimal()
}
}
}
}
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
finalizedBy(tasks.generateJacocoBadge)
}
val jacocoExcludePatterns = listOf("**/*Application.class", "**/*ApplicationKt.class", "**/Constants.class")
listOf(JacocoCoverageVerification::class, JacocoReport::class).forEach { taskType ->
tasks.withType(taskType) {
afterEvaluate {
classDirectories.setFrom(
files(
classDirectories.files.map { file ->
fileTree(file).apply {
exclude(jacocoExcludePatterns)
}
}
)
)
}
}
}