blob: f94275272f4155b959074f00f461458ccba5bbe0 (
plain)
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
|
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
configure(subprojects) {
val project = this
if (name in sourceless) return@configure
apply(plugin = "kotlinx-atomicfu")
tasks.withType<KotlinCompilationTask<*>>().configureEach {
val isMainTaskName = name.startsWith("compileKotlin")
compilerOptions {
var versionsAreNotOverridden = true
getOverriddenKotlinLanguageVersion(project)?.let {
languageVersion = it
versionsAreNotOverridden = false
}
getOverriddenKotlinApiVersion(project)?.let {
apiVersion = it
versionsAreNotOverridden = false
}
if (isMainTaskName && versionsAreNotOverridden) {
allWarningsAsErrors = true
freeCompilerArgs.add("-Xexplicit-api=strict")
}
/* Coroutines do not interop with Java and these flags provide a significant
* (i.e. close to double-digit) reduction in both bytecode and optimized dex size */
if (this@configureEach is KotlinJvmCompile) {
freeCompilerArgs.addAll(
"-Xno-param-assertions",
"-Xno-call-assertions",
"-Xno-receiver-assertions"
)
}
if (this@configureEach is KotlinNativeCompile) {
optIn.addAll(
"kotlinx.cinterop.ExperimentalForeignApi",
"kotlinx.cinterop.UnsafeNumber",
"kotlin.experimental.ExperimentalNativeApi",
)
}
freeCompilerArgs.addAll("-progressive", "-Xexpect-actual-classes")
optIn.addAll(
"kotlin.experimental.ExperimentalTypeInference",
"kotlin.ExperimentalMultiplatform",
// our own opt-ins that we don't want to bother with in our own code:
"kotlinx.coroutines.DelicateCoroutinesApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.ObsoleteCoroutinesApi",
"kotlinx.coroutines.InternalCoroutinesApi",
"kotlinx.coroutines.FlowPreview"
)
}
}
}
|