-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
166 lines (145 loc) · 5.43 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
import java.net.URL
buildscript {
// Starting from Kotlin 2.1.0, KGP doesn't depend on the `kotlin-compiler-embeddable`.
// Other plugins can bring incompatible versions of the compiler.
// https://kotlinlang.slack.com/archives/C0KLZSCHF/p1729256644747559?thread_ts=1729151089.194689&cid=C0KLZSCHF
dependencies.classpath(libs.kotlin.compiler.embeddable)
}
plugins {
alias(libs.plugins.android.lib) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.atomicfu) apply false
alias(libs.plugins.kotlinx.bcv) apply false
alias(libs.plugins.kotlinx.kover)
alias(libs.plugins.dokka) apply false
alias(libs.plugins.fluxo.bcv.js) apply false
alias(libs.plugins.gradle.doctor) apply false
alias(libs.plugins.vanniktech.mvn.publish) apply false
alias(libs.plugins.fluxo.kmp.conf)
}
// Setup project defaults.
fkcSetupRaw {
explicitApi()
projectName = "fluxo-io"
description = "I/O functionality for Kotlin Multiplatform from Fluxo"
githubProject = "fluxo-kt/fluxo-io"
group = "io.github.fluxo-kt"
publicationConfig {
developerId = "amal"
developerName = "Art Shendrik"
developerEmail = "artyom.shendrik@gmail.com"
sonatypeHost = com.vanniktech.maven.publish.SonatypeHost.S01
}
enableApiValidation = true
setupVerification = true
enableGenericAndroidLint = true
enableGradleDoctor = true
experimentalLatestCompilation = true
latestSettingsForTests = true
allWarningsAsErrors = false
optInInternal = true
optIns = listOf(
"kotlin.ExperimentalStdlibApi",
"kotlin.js.ExperimentalJsExport",
)
}
kover.reports {
dependencies {
kover(projects.fluxoIoRad)
}
// TODO: Disable Kover by default to reduce performance penalty.
// https://github.com/Kotlin/kotlinx-kover/issues/531#issuecomment-1929483468
val isCI by isCI()
val isRelease by isRelease()
filters {
// Test classes
excludes.classes("*Test")
}
verify {
@Suppress("MagicNumber")
rule {
disabled = false
groupBy = kotlinx.kover.gradle.plugin.dsl.GroupingEntityType.APPLICATION
minBound(55)
bound {
minValue = 80
coverageUnits = kotlinx.kover.gradle.plugin.dsl.CoverageUnit.LINE
aggregationForGroup =
kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE
}
bound {
minValue = 80
coverageUnits = kotlinx.kover.gradle.plugin.dsl.CoverageUnit.INSTRUCTION
aggregationForGroup =
kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE
}
bound {
minValue = 55
coverageUnits = kotlinx.kover.gradle.plugin.dsl.CoverageUnit.BRANCH
aggregationForGroup =
kotlinx.kover.gradle.plugin.dsl.AggregationType.COVERED_PERCENTAGE
}
}
}
total {
xml {
onCheck = true
xmlFile = layout.buildDirectory.file("reports/kover-merged-report.xml")
}
log {
onCheck = true
}
html {
onCheck = !isCI && isRelease
htmlDir = layout.buildDirectory.dir("reports/kover-merged-report-html")
}
}
}
allprojects {
// FIXME: Setup automatically.
plugins.withType<org.jetbrains.dokka.gradle.DokkaPlugin> {
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
dokkaSourceSets {
configureEach {
if (name.startsWith("ios")) {
displayName.set("ios")
}
sourceLink {
localDirectory.set(rootDir)
@Suppress("DEPRECATION")
remoteUrl.set(URL("https://github.com/fluxo-kt/fluxo-io/blob/main"))
remoteLineSuffix.set("#L")
}
}
}
}
}
}
/**
* Find Android SDK JAR for usage as a dependency in non-android modules or source sets.
*/
fun findAndroidJar(project: Project, compileSdkVersion: Int): FileCollection {
fun getSdkDirFromLocalProperties(): String? {
// Get "sdk.dir" property from local.properties file.
return project.file("local.properties")
.takeIf { it.exists() }
?.run {
readLines().firstOrNull { it.startsWith("sdk.dir=") }
?.substringAfter("sdk.dir=")
}
}
fun findAndroidSdkDir(): String? {
// https://developer.android.com/studio/command-line/variables
return getSdkDirFromLocalProperties()
?: System.getenv("ANDROID_SDK_ROOT")
?: System.getenv("ANDROID_HOME")
?: System.getProperty("android.home")
}
// References:
// https://android.googlesource.com/platform/tools/base/+/f6bef46dc8/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/SdkHandler.java#319
// https://github.com/stepango/android-jar
val androidSdkDir = findAndroidSdkDir()
?: throw java.io.FileNotFoundException("Can't locate Android SDK path")
return project.files("$androidSdkDir/platforms/android-$compileSdkVersion/android.jar")
}
extra["androidJar"] = findAndroidJar(project, libs.versions.androidCompileSdk.get().toInt())