-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
177 lines (160 loc) · 5.31 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
classpath("com.android.tools.build:gradle:7.2.2")
classpath(Plugin.kotlin)
classpath(Plugin.kotlinxSerialization)
classpath(Plugin.proguard)
classpath(Plugin.junitAndroid)
}
}
plugins {
id(Plugin.Id.detekt) version Versions.detekt
id(Plugin.Id.kover) version Versions.kover
id(Plugin.Id.ktfmt) version Versions.ktfmtGradle
}
group = "org.chiachat"
version = "1.0.0"
tasks {
val checkAndDetekt by
registering(io.gitlab.arturbosch.detekt.Detekt::class) {
dependsOn("check")
description = "Runs detekt static code analysis on all modules"
buildUponDefaultConfig = true
allRules = true
parallel = true
ignoreFailures = false
setSource(files(projectDir))
include("**/*.kt")
exclude("**/resources/**")
exclude("**/build/**")
config.setFrom("$rootDir/config/detekt/detekt.yml")
baseline.set(file("$rootDir/config/detekt/baseline.xml"))
reports {
html.required.set(true)
xml.required.set(true)
sarif.required.set(true)
}
}
val detektProjectBaseline by
registering(io.gitlab.arturbosch.detekt.DetektCreateBaselineTask::class) {
description = "Overrides current baseline."
buildUponDefaultConfig.set(true)
ignoreFailures.set(true)
parallel.set(true)
setSource(files(rootDir))
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
baseline.set(file("$rootDir/config/detekt/baseline.xml"))
include("**/*.kt")
exclude("**/resources/**")
exclude("**/build/**")
}
}
val detektReportMergeSarif by
tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) {
output.set(rootProject.layout.buildDirectory.file("reports/detekt/merge.sarif"))
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
google()
maven { url = uri("https://jitpack.io") }
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
}
subprojects {
apply(plugin = Plugin.Id.detekt)
detekt {
source =
objects
.fileCollection()
.from(
io.gitlab.arturbosch.detekt.extensions.DetektExtension.DEFAULT_SRC_DIR_JAVA,
io.gitlab.arturbosch.detekt.extensions.DetektExtension.DEFAULT_TEST_SRC_DIR_JAVA,
io.gitlab.arturbosch.detekt.extensions.DetektExtension.DEFAULT_SRC_DIR_KOTLIN,
io.gitlab.arturbosch.detekt.extensions.DetektExtension.DEFAULT_TEST_SRC_DIR_KOTLIN,
)
buildUponDefaultConfig = true
baseline = file("$rootDir/config/detekt/baseline.xml")
}
tasks.withType<io.gitlab.arturbosch.detekt.Detekt> detekt@{
jvmTarget = "17"
reports {
xml.required.set(true)
html.required.set(true)
txt.required.set(true)
sarif.required.set(true)
md.required.set(true)
}
basePath = rootProject.projectDir.absolutePath
finalizedBy(detektReportMergeSarif)
detektReportMergeSarif.configure { input.from(this@detekt.sarifReportFile) }
}
tasks.withType<io.gitlab.arturbosch.detekt.DetektCreateBaselineTask>().configureEach {
jvmTarget = "17"
}
tasks {
whenTaskAdded {
if (name == "testDebugUnitTest") {
this.enabled = false
}
}
}
}
val rootPackage = "org.chiachat.app"
val basePackage = listOf("*", "compose").map { "$rootPackage.$it" }
val excludedPackages =
listOf("type", "selections", "adapter", "apollo", "test", "android.test", "compose").map {
"$rootPackage.$it.*"
} + "*.BuildConfig" + "*.MainActivity" + "*.**Test" + "*.**Module**" + "*.ChiaChatDbImpl*"
koverMerged {
enable() // create Kover merged report tasks from this project and subprojects with enabled Kover
// plugin
filters {
classes {
includes += basePackage
excludes += excludedPackages
}
projects { excludes += listOf(":androidApp", ":desktopApp", ":iosApp", ":webApp") }
}
xmlReport {
enable()
onCheck.set(true)
reportFile.set(layout.buildDirectory.file("reports/kover/xml/report.xml"))
}
htmlReport {
enable()
onCheck.set(true)
reportDir.set(layout.buildDirectory.dir("reports/kover/html"))
}
verify {
// set to true to run koverMergedVerify task during the execution of the check task
// (if it exists) of the current project
onCheck.set(true)
rule { // add verification rule
// set to false to disable rule checking
isEnabled = true
// custom name for the rule
name = "Minimum Test Coverage"
// specify by which entity the code for separate coverage evaluation will be
target = kotlinx.kover.api.VerificationTarget.ALL
// grouped
bound { // add rule bound
minValue = 25
maxValue = 100
// change coverage metric to evaluate (LINE, INSTRUCTION, BRANCH)
counter = kotlinx.kover.api.CounterType.LINE
// change counter value (COVERED_COUNT, MISSED_COUNT,
// COVERED_PERCENTAGE, MISSED_PERCENTAGE)
valueType = kotlinx.kover.api.VerificationValueType.COVERED_PERCENTAGE
}
}
}
}