-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
122 lines (110 loc) · 4.08 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
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
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidApplication).apply(false)
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.kotlinSerialization).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
alias(libs.plugins.composeMultiplatform).apply(false)
alias(libs.plugins.jetbrainsCompose).apply(false)
alias(libs.plugins.kotlinJvm).apply(false)
alias(libs.plugins.detekt)
alias(libs.plugins.kover)
}
tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.addAll(
listOf(
"-Xconsistent-data-class-copy-visibility",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
)
}
}
val defaultRequiredMinimumCoverage = 80
val defaultRequiredMaximumCoverage = 100
allprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "org.jetbrains.kotlinx.kover")
val koverExcludeList = listOf(
"*Activity",
"*Activity\$*",
"*.databinding.*",
"*.BuildConfig",
"*ComposableSingletons",
"*_Factory",
"*ComposableSingletons",
)
val koverIncludeList = listOf("*.viewmodel.*", "*.data.service.*")
val koverProjectNames = listOf("data", "viewmodel", "composeApp")
extensions.configure<DetektExtension> {
autoCorrect = true
source.setFrom(
objects.fileCollection().from(
DetektExtension.DEFAULT_SRC_DIR_JAVA,
DetektExtension.DEFAULT_TEST_SRC_DIR_JAVA,
DetektExtension.DEFAULT_SRC_DIR_KOTLIN,
DetektExtension.DEFAULT_TEST_SRC_DIR_KOTLIN,
"src/androidMain",
"src/commonMain",
"src/iosMain",
"src/commonTest",
"src/iosTest",
"src/androidUnitTest",
"src/test",
"src/testDebug",
"src/testRelease",
"build.gradle.kts",
)
)
buildUponDefaultConfig = false
config.setFrom(files("$rootDir/config/detekt.yml"))
}
tasks.withType<Detekt>().configureEach {
jvmTarget = libs.versions.javaTargetCompatibility.get()
reports {
html.required.set(true)
xml.required.set(true)
}
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = libs.versions.javaTargetCompatibility.get()
}
if (koverProjectNames.any { project.name.contains(it) }) {
kover {
reports {
filters {
excludes { classes(koverExcludeList) }
includes { classes(koverIncludeList) }
}
total {
filters {
excludes { classes(koverExcludeList) }
includes { classes(koverIncludeList) }
}
verify {
rule("Minimum coverage verification error") {
disabled = false
groupBy = kotlinx.kover.gradle.plugin.dsl.GroupingEntityType.APPLICATION
bound {
minValue.set(defaultRequiredMinimumCoverage)
maxValue.set(defaultRequiredMaximumCoverage)
coverageUnits.set(CoverageUnit.LINE)
aggregationForGroup =
kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE
}
}
}
}
}
}
}
}
dependencies {
detektPlugins(libs.detekt.formatting)
}