-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
168 lines (161 loc) · 5.73 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
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import io.gitlab.arturbosch.detekt.report.ReportMergeTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
val versionManager: String by project
//jitpack 构建
classpath("com.github.storytellerF.common-ui-list:version-manager:$versionManager")
//本地构建
// classpath("com.storyteller_f:version-manager:0.0.1-local")
}
}
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
alias(libs.plugins.googleKsp) apply false
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("org.jetbrains.kotlinx.kover") version "0.7.4"
id("com.starter.easylauncher") version ("6.2.0") apply false
}
setupDeprecationCheck(listOf(""))
setupDetekt()
setupKover(
"app",
listOf(
"file-system",
"file-system-archive",
"file-system-ktx",
"file-system-local",
"file-system-memory",
"file-system-remote",
"file-system-root",
), listOf()
)
tasks.withType<Test> {
testLogging {
exceptionFormat = TestExceptionFormat.FULL
events = setOf(
TestLogEvent.STARTED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED,
TestLogEvent.PASSED
)
showStandardStreams = true
}
}
fun Project.setupDetekt() {
val detektReportMergeSarif by tasks.registering(ReportMergeTask::class) {
output = layout.buildDirectory.file("reports/detekt/merge.sarif")
}
subprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
detekt {
source.setFrom(
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
autoCorrect = true
config.setFrom("$rootDir/config/detekt/detekt.yml")
baseline = file("$rootDir/config/detekt/baseline.xml")
}
dependencies {
val detektVersion = "1.23.1"
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:$detektVersion")
//noinspection UseTomlInstead
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-ruleauthors:$detektVersion")
}
tasks.withType<Detekt>().configureEach {
jvmTarget = "1.8"
reports {
xml.required = true
html.required = true
txt.required = true
sarif.required = true
md.required = true
}
basePath = rootDir.absolutePath
finalizedBy(detektReportMergeSarif)
}
detektReportMergeSarif {
input.from(
tasks.withType<Detekt>().map { it.sarifReportFile })
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
jvmTarget = "1.8"
}
}
}
fun Project.setupKover(
mainModule: String,
androidLibModules: List<String>,
jvmLibModules: List<String>
) {
subprojects {
apply(plugin = "org.jetbrains.kotlinx.kover")
//虽然模块本身已经设置了com.android.library 但是这里依然需要添加
if (androidLibModules.contains(name)) {
apply(plugin = "com.android.library")
}
dependencies {
if (name == mainModule) {
val action = { it: String ->
kover(project(":$it"))
Unit
}
androidLibModules.forEach(action)
jvmLibModules.forEach(action)
}
if (androidLibModules.contains(name)) {
val robolectricVersion = "4.11.1"
"testImplementation"("org.robolectric:robolectric:$robolectricVersion")
}
}
koverReport {
if (androidLibModules.contains(name)) {
defaults {
mergeWith("release")
}
}
// filters for all report types of all build variants
filters {
excludes {
classes(
"*Fragment",
"*Fragment\$*",
"*Activity",
"*Activity\$*",
"*.databinding.*",
"*.BuildConfig"
)
}
}
}
}
}
fun Project.setupDeprecationCheck(deprecationCheckModules: List<String>) {
subprojects {
if (deprecationCheckModules.contains(name)) {
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs =
freeCompilerArgs + listOf("-Xlint:deprecation", "-Xlint:unchecked")
}
}
tasks.withType<JavaCompile> {
options.compilerArgs =
options.compilerArgs + listOf("-Xlint:deprecation", "-Xlint:unchecked")
}
}
}
}