forked from hoc081098/GithubSearchKMM-Compose-SwiftUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
184 lines (163 loc) · 5.12 KB
/
build.gradle.kts
File metadata and controls
184 lines (163 loc) · 5.12 KB
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
178
179
180
181
182
183
184
import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import com.github.benmanes.gradle.versions.VersionsPlugin
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import java.util.EnumSet
import kotlinx.kover.KoverPlugin
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}")
classpath(kotlin("serialization", version = versions.kotlin))
classpath("org.jetbrains.kotlinx:kover:0.6.1")
classpath("com.android.tools.build:gradle:${versions.agp}")
classpath("com.google.dagger:hilt-android-gradle-plugin:${deps.dagger.version}")
classpath("com.diffplug.spotless:spotless-plugin-gradle:${versions.spotless}")
classpath("com.github.ben-manes:gradle-versions-plugin:${versions.gradleVersions}")
classpath("com.squareup:javapoet:1.13.0")
classpath("dev.icerock.moko:kswift-gradle-plugin:${versions.mokoKSwift}")
}
}
plugins {
id("com.google.devtools.ksp") version "1.7.20-1.0.7" apply false
}
allprojects {
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
languageVersion = "1.8"
}
}
repositories {
google()
mavenCentral()
maven(url = "https://jitpack.io")
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
// TODO: Workaround for https://github.com/google/dagger/issues/3448, https://github.com/google/dagger/issues/3459
configurations.all {
resolutionStrategy.eachDependency {
if (requested.module.group == "org.jetbrains.kotlin" &&
requested.module.name.startsWith("kotlin-stdlib")
) {
useVersion(versions.kotlin)
}
}
}
}
allprojects {
apply<KoverPlugin>()
configure<kotlinx.kover.api.KoverMergedConfig> {
enable()
}
configure<kotlinx.kover.api.KoverProjectConfig> {
filters { // common filters for all default Kover tasks
classes { // common class filter for all default Kover tasks in this project
excludes += excludedClasses
}
}
}
apply<SpotlessPlugin>()
configure<SpotlessExtension> {
val editorConfigKeys: Set<String> = hashSetOf(
"ij_kotlin_imports_layout",
"indent_size",
"end_of_line",
"charset",
"continuation_indent_size"
)
kotlin {
target("**/*.kt")
// TODO this should all come from editorconfig https://github.com/diffplug/spotless/issues/142
val data = M[
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"continuation_indent_size" to "4",
"disabled_rules" to L[
"experimental:package-name",
"experimental:trailing-comma",
"experimental:type-parameter-list-spacing",
"filename",
"annotation"
].joinToString(separator = ",")
]
ktlint(versions.ktlint)
.setUseExperimental(true)
.userData(data.filterKeys { it !in editorConfigKeys })
.editorConfigOverride(data.filterKeys { it in editorConfigKeys })
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
format("xml") {
target("**/res/**/*.xml")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
kotlinGradle {
target("**/*.gradle.kts", "*.gradle.kts")
val data = M[
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"continuation_indent_size" to "4"
]
ktlint(versions.ktlint)
.setUseExperimental(true)
.userData(data.filterKeys { it !in editorConfigKeys })
.editorConfigOverride(data.filterKeys { it in editorConfigKeys })
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
}
subprojects {
apply<KoverPlugin>()
apply<VersionsPlugin>()
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return !isStable
}
fun isStable(version: String) = !isNonStable(version)
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
if (isStable(currentVersion)) {
isNonStable(candidate.version)
} else {
false
}
}
}
afterEvaluate {
tasks.withType<Test> {
testLogging {
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
events = EnumSet.of(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
)
exceptionFormat = TestExceptionFormat.FULL
}
}
}
}