diff --git a/build-logic/plugins/src/main/kotlin/AndroidSampleApplicationPlugin.kt b/build-logic/plugins/src/main/kotlin/AndroidSampleApplicationPlugin.kt index 0ee0acc15..dbf0c2456 100644 --- a/build-logic/plugins/src/main/kotlin/AndroidSampleApplicationPlugin.kt +++ b/build-logic/plugins/src/main/kotlin/AndroidSampleApplicationPlugin.kt @@ -2,14 +2,9 @@ import com.android.build.gradle.internal.dsl.BaseAppModuleExtension import extensions.configureDesugaring import extensions.configureKotlinAndroid -import extensions.stringBuildConfigField -import extensions.toProperties import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.getByType class AndroidSampleApplicationPlugin: Plugin { override fun apply(target: Project) { diff --git a/build-logic/plugins/src/main/kotlin/MultiplatformLibraryPlugin.kt b/build-logic/plugins/src/main/kotlin/MultiplatformLibraryPlugin.kt index 0f30eb602..afb92005b 100644 --- a/build-logic/plugins/src/main/kotlin/MultiplatformLibraryPlugin.kt +++ b/build-logic/plugins/src/main/kotlin/MultiplatformLibraryPlugin.kt @@ -1,5 +1,6 @@ import com.android.build.gradle.LibraryExtension +import extensions.configureDesugaring import extensions.configureKotlinAndroid import extensions.configureKotlinCompiler import org.gradle.api.Plugin @@ -16,6 +17,7 @@ class MultiplatformLibraryPlugin: Plugin { extensions.configure { configureKotlinAndroid(this) configureKotlinCompiler(jvmVersion = 17) + configureDesugaring(this) sourceSets.getByName("main").manifest.srcFile("src/androidMain/AndroidManifest.xml") defaultConfig.targetSdk = 34 } @@ -23,4 +25,4 @@ class MultiplatformLibraryPlugin: Plugin { tasks.register("testClasses") } } -} \ No newline at end of file +} diff --git a/build-logic/plugins/src/main/kotlin/extensions/Kotlin.kt b/build-logic/plugins/src/main/kotlin/extensions/Kotlin.kt index ccc4e8861..85b5ec613 100644 --- a/build-logic/plugins/src/main/kotlin/extensions/Kotlin.kt +++ b/build-logic/plugins/src/main/kotlin/extensions/Kotlin.kt @@ -11,7 +11,12 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile internal fun Project.configureKotlinCompiler(jvmVersion: Int) { this.tasks.withType { - kotlinOptions.jvmTarget = JavaVersion.toVersion(jvmVersion).toString() + kotlinOptions { + freeCompilerArgs = freeCompilerArgs + listOf( + "-opt-in=kotlin.RequiresOptIn" + ) + jvmTarget = JavaVersion.toVersion(jvmVersion).toString() + } } tasks.withType { val javaToolchains = project.extensions.getByType() diff --git a/build-logic/plugins/src/main/kotlin/extensions/KotlinAndroid.kt b/build-logic/plugins/src/main/kotlin/extensions/KotlinAndroid.kt index cf82e2948..8fa1af7a4 100644 --- a/build-logic/plugins/src/main/kotlin/extensions/KotlinAndroid.kt +++ b/build-logic/plugins/src/main/kotlin/extensions/KotlinAndroid.kt @@ -5,9 +5,7 @@ package extensions import com.android.build.api.dsl.CommonExtension import org.gradle.api.JavaVersion import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.dependencies -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions internal fun configureKotlinAndroid( commonExtension: CommonExtension<*, *, *, *, *, *>, @@ -33,20 +31,9 @@ internal fun Project.configureDesugaring( compileOptions { isCoreLibraryDesugaringEnabled = true } - - kotlinOptions { - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn" - ) - jvmTarget = JavaVersion.VERSION_17.toString() - } } dependencies { add("coreLibraryDesugaring", "com.android.tools:desugar_jdk_libs:1.1.5") } } - -private fun CommonExtension<*, *, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { - (this as ExtensionAware).extensions.configure("kotlinOptions", block) -}