-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathconfigure-compilation-conventions.gradle.kts
39 lines (37 loc) · 1.53 KB
/
configure-compilation-conventions.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
import org.jetbrains.kotlin.gradle.tasks.*
configure(subprojects) {
val project = this
if (name in sourceless) return@configure
apply(plugin = "org.jetbrains.kotlinx.atomicfu")
tasks.withType<KotlinCompilationTask<*>>().configureEach {
val isMainTaskName = name.startsWith("compileKotlin")
compilerOptions {
getOverriddenKotlinLanguageVersion(project)?.let {
languageVersion = it
}
getOverriddenKotlinApiVersion(project)?.let {
apiVersion = it
}
if (isMainTaskName && !unpublished.contains(project.name)) {
allWarningsAsErrors = true
freeCompilerArgs.addAll("-Xexplicit-api=strict", "-Xdont-warn-on-error-suppression")
}
/* 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",
)
}
}
}
}