diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index 28fc2b429..c04e7a916 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -15,6 +15,7 @@ * see . */ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -30,8 +31,8 @@ java { targetCompatibility = JavaVersion.VERSION_17 } tasks.withType().configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/build-logic/convention/src/main/kotlin/app/pachli/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/app/pachli/KotlinAndroid.kt index d932a0b80..08a2218ec 100644 --- a/build-logic/convention/src/main/kotlin/app/pachli/KotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/app/pachli/KotlinAndroid.kt @@ -19,9 +19,11 @@ import app.pachli.libs import com.android.build.api.dsl.CommonExtension import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.kotlin.dsl.assign import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile /** @@ -82,13 +84,13 @@ internal fun Project.configureKotlinJvm() { private fun Project.configureKotlin() { // Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947 tasks.withType().configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) // Treat all Kotlin warnings as errors (disabled by default) // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties val warningsAsErrors: String? by project allWarningsAsErrors = warningsAsErrors.toBoolean() - freeCompilerArgs = freeCompilerArgs + listOf( + freeCompilerArgs.addAll( "-opt-in=kotlin.RequiresOptIn", // Enable experimental coroutines APIs, including Flow "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",