Skip to content

Commit 03308fd

Browse files
committed
Migration kotlinOptions to compilerOptions
1 parent 86a00e8 commit 03308fd

File tree

1 file changed

+24
-20
lines changed
  • build-logic/convention/src/main/kotlin/io/getstream/whatsappclone

1 file changed

+24
-20
lines changed

build-logic/convention/src/main/kotlin/io/getstream/whatsappclone/KotlinAndroid.kt

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import com.android.build.api.dsl.CommonExtension
44
import org.gradle.api.JavaVersion
55
import org.gradle.api.Project
66
import org.gradle.api.plugins.ExtensionAware
7+
import org.gradle.kotlin.dsl.provideDelegate
8+
import org.gradle.kotlin.dsl.withType
9+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
710
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
11+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
812

913
/**
1014
* Configure base Kotlin with Android options
@@ -28,26 +32,26 @@ internal fun Project.configureKotlinAndroid(
2832
abortOnError = false
2933
}
3034

31-
kotlinOptions {
32-
// Treat all Kotlin warnings as errors (disabled by default)
33-
allWarningsAsErrors = properties["warningsAsErrors"] as? Boolean ?: false
34-
35-
freeCompilerArgs = freeCompilerArgs + listOf(
36-
"-opt-in=kotlin.RequiresOptIn",
37-
// Enable experimental coroutines APIs, including Flow
38-
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
39-
// Enable experimental compose APIs
40-
"-opt-in=com.google.accompanist.pager.ExperimentalPagerApi",
41-
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
42-
"-opt-in=androidx.lifecycle.compose.ExperimentalLifecycleComposeApi",
43-
)
44-
45-
// Set JVM target to 11
46-
jvmTarget = JavaVersion.VERSION_17.toString()
35+
tasks.withType<KotlinCompile>().configureEach {
36+
compilerOptions {
37+
val warningsAsErrors: String? by project
38+
// Treat all Kotlin warnings as errors (disabled by default)
39+
allWarningsAsErrors.set(warningsAsErrors.toBoolean())
40+
41+
freeCompilerArgs.addAll(
42+
listOf(
43+
"-opt-in=kotlin.RequiresOptIn",
44+
// Enable experimental coroutines APIs, including Flow
45+
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
46+
// Enable experimental compose APIs
47+
"-opt-in=com.google.accompanist.pager.ExperimentalPagerApi",
48+
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
49+
"-opt-in=androidx.lifecycle.compose.ExperimentalLifecycleComposeApi",
50+
)
51+
)
52+
53+
jvmTarget.set(JvmTarget.JVM_17)
54+
}
4755
}
4856
}
4957
}
50-
51-
fun CommonExtension<*, *, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
52-
(this as ExtensionAware).extensions.configure("kotlinOptions", block)
53-
}

0 commit comments

Comments
 (0)