From 4ac4d3da017d47448db4ccb41eacf0f74e6c0605 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Wed, 4 Feb 2026 20:11:16 +0800 Subject: [PATCH] Migrate to AGP KMP --- benchmark/build.gradle.kts | 1 - .../AndroidApplicationConventionPlugin.kt | 3 +-- .../MultiplatformLibraryConventionPlugin.kt | 6 +----- .../src/main/kotlin/com/ehviewer/Kotlin.kt | 12 ++++++++---- build.gradle.kts | 1 - core/i18n/build.gradle.kts | 18 ++++-------------- gradle.properties | 9 --------- gradle/libs.versions.toml | 3 +-- 8 files changed, 15 insertions(+), 38 deletions(-) diff --git a/benchmark/build.gradle.kts b/benchmark/build.gradle.kts index 86b9d2340..7275e7d1d 100644 --- a/benchmark/build.gradle.kts +++ b/benchmark/build.gradle.kts @@ -1,6 +1,5 @@ plugins { alias(libs.plugins.android.test) - alias(libs.plugins.android.builtInKotlin) alias(libs.plugins.baselineprofile) } diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt index 435fb6293..7ec474de5 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -17,14 +17,13 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidExtension class AndroidApplicationConventionPlugin : Plugin { override fun apply(target: Project) = with(target) { apply(plugin = libs.plugins.android.application.get().pluginId) - apply(plugin = libs.plugins.android.builtInKotlin.get().pluginId) apply(plugin = libs.plugins.compose.compiler.get().pluginId) apply(plugin = libs.plugins.composeCompilerReportGenerator.get().pluginId) configure { jvmToolchain(21) compilerOptions { - configureKotlin() + configureKotlin(includeKotlinX = true) configureKotlinCompose() jvmDefault = JvmDefaultMode.NO_COMPATIBILITY } diff --git a/build-logic/convention/src/main/kotlin/MultiplatformLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/MultiplatformLibraryConventionPlugin.kt index 8b05db5db..3e501dff9 100644 --- a/build-logic/convention/src/main/kotlin/MultiplatformLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/MultiplatformLibraryConventionPlugin.kt @@ -24,7 +24,7 @@ class MultiplatformLibraryConventionPlugin : Plugin { configure { jvmToolchain(21) compilerOptions { - configureKotlin() + configureKotlin(includeKotlinX = path != ":core:i18n") } applyHierarchyTemplate { @@ -44,10 +44,6 @@ class MultiplatformLibraryConventionPlugin : Plugin { configure { namespace = "com.ehviewer${path.replace(':', '.')}" - - withHostTestBuilder { - } - enableCoreLibraryDesugaring = true compilerOptions { diff --git a/build-logic/convention/src/main/kotlin/com/ehviewer/Kotlin.kt b/build-logic/convention/src/main/kotlin/com/ehviewer/Kotlin.kt index 80f745e91..cbc2e8b8b 100644 --- a/build-logic/convention/src/main/kotlin/com/ehviewer/Kotlin.kt +++ b/build-logic/convention/src/main/kotlin/com/ehviewer/Kotlin.kt @@ -4,7 +4,7 @@ import org.gradle.kotlin.dsl.assign import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions // https://kotlinlang.org/docs/gradle-compiler-options.html#all-compiler-options -internal fun KotlinCommonCompilerOptions.configureKotlin() { +internal fun KotlinCommonCompilerOptions.configureKotlin(includeKotlinX: Boolean) { progressiveMode = true allWarningsAsErrors = true optIn.addAll( @@ -12,10 +12,14 @@ internal fun KotlinCommonCompilerOptions.configureKotlin() { "kotlin.concurrent.atomics.ExperimentalAtomicApi", "kotlin.contracts.ExperimentalContracts", "kotlin.time.ExperimentalTime", - "kotlinx.coroutines.ExperimentalCoroutinesApi", - "kotlinx.coroutines.FlowPreview", - "kotlinx.serialization.ExperimentalSerializationApi", ) + if (includeKotlinX) { + optIn.addAll( + "kotlinx.coroutines.ExperimentalCoroutinesApi", + "kotlinx.coroutines.FlowPreview", + "kotlinx.serialization.ExperimentalSerializationApi", + ) + } freeCompilerArgs.addAll( "-Xcontext-parameters", "-Xwhen-expressions=indy", diff --git a/build.gradle.kts b/build.gradle.kts index 79011325f..624b365f2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ plugins { alias(libs.plugins.android.application) apply false - alias(libs.plugins.android.builtInKotlin) apply false alias(libs.plugins.android.kotlin.multiplatform.library) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.android.lint) apply false diff --git a/core/i18n/build.gradle.kts b/core/i18n/build.gradle.kts index 44e4cc88e..e9bf05eff 100644 --- a/core/i18n/build.gradle.kts +++ b/core/i18n/build.gradle.kts @@ -1,14 +1,9 @@ plugins { - alias(libs.plugins.android.library) - alias(libs.plugins.kotlin.multiplatform) + alias(libs.plugins.ehviewer.multiplatform.library) alias(libs.plugins.moko.resources) } kotlin { - // TODO: Migrate to AGP KMP - // https://github.com/icerockdev/moko-resources/issues/820 - androidTarget() - sourceSets { commonMain { dependencies { @@ -17,16 +12,11 @@ kotlin { } } - jvmToolchain(21) compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") } -} -android { - namespace = "com.ehviewer.core.i18n" -} - -multiplatformResources { - resourcesPackage = "com.ehviewer.core.i18n" + multiplatformResources { + resourcesPackage = android.namespace + } } diff --git a/gradle.properties b/gradle.properties index 290fe566e..97fd3083e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,12 +18,3 @@ org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC org.gradle.parallel=true org.gradle.caching=true org.gradle.configuration-cache=true - -# https://github.com/icerockdev/moko-resources/issues/820 -android.builtInKotlin=false - -# https://issuetracker.google.com/443268525 -android.newDsl=false - -# https://github.com/icerockdev/moko-resources/issues/852 -android.sourceset.disallowProvider=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 622e68d99..fe1104d42 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -aboutlibraries = "13.2.1" +aboutlibraries = "14.0.0-b02" accompanist = "0.37.3" agp = "9.0.0" androidx-activity = "1.12.3" @@ -144,7 +144,6 @@ splitties = ["splitties-appctx", "splitties-systemservices"] aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutlibraries" } aboutlibrariesAndroid = { id = "com.mikepenz.aboutlibraries.plugin.android", version.ref = "aboutlibraries" } android-application = { id = "com.android.application", version.ref = "agp" } -android-builtInKotlin = { id = "com.android.built-in-kotlin", version.ref = "agp" } android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" } android-library = { id = "com.android.library", version.ref = "agp" } android-lint = { id = "com.android.lint", version.ref = "agp" }