-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle.kts
71 lines (56 loc) · 2.03 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
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
group = MiraiCompose.group
version = MiraiCompose.version
allprojects {
repositories {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
}
afterEvaluate {
configureEncoding()
configureKotlinExperimentalUsages()
configureKotlinCompilerSettings()
}
}
val experimentalAnnotations = arrayOf(
"kotlin.Experimental",
"kotlin.RequiresOptIn",
"kotlin.ExperimentalUnsignedTypes",
"kotlin.ExperimentalStdlibApi",
"kotlin.experimental.ExperimentalTypeInference",
)
fun Project.configureEncoding() {
tasks.withType<JavaCompile>() {
options.encoding = "UTF8"
}
}
fun Project.configureKotlinExperimentalUsages() {
val sourceSets = kotlinSourceSets ?: return
for (target in sourceSets)
target.languageSettings.run {
progressiveMode = true
experimentalAnnotations.forEach { a ->
optIn(a)
}
}
}
fun Project.configureKotlinCompilerSettings() {
val kotlinCompilations = kotlinCompilations ?: return
for (kotlinCompilation in kotlinCompilations) with(kotlinCompilation) {
if (isKotlinJvmProject) {
@Suppress("UNCHECKED_CAST")
this as org.jetbrains.kotlin.gradle.plugin.KotlinCompilation<KotlinJvmOptions>
}
kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"
}
}
val Project.kotlinSourceSets get() = extensions.findByName("kotlin").safeAs<KotlinProjectExtension>()?.sourceSets
val Project.isKotlinJvmProject: Boolean get() = extensions.findByName("kotlin") is KotlinJvmProjectExtension
val Project.kotlinTargets
get() =
extensions.findByName("kotlin").safeAs<KotlinSingleTargetExtension>()?.target?.let { listOf(it) }
?: extensions.findByName("kotlin").safeAs<KotlinMultiplatformExtension>()?.targets
val Project.kotlinCompilations
get() = kotlinTargets?.flatMap { it.compilations }