Repository navigation
Fix #6228, part of #6233: Migrate to Kotlin 1.9 [Blocked: #6234] - #6235
BenHenning wants to merge 4 commits into
Conversation
This won't build yet due to Moshi warnings triggering warning-as-errors. However, with warnings-as-errors disabled this does build even //:oppia_alpha and tests at least including StateFragmentTest pass. No comprehensive static checks have been completed yet. This was completely done by Gemini CLI with tons of prompting back-and-forth with me to get the correct outcome.
This was entirely generated by Gemini CLI and //:oppia_alpha and StateFragmentTest have been verified. There are definitely some issues and things to double check, but this satsifies the main need of being able to build 1.9 with warnigns-as-errors still enabled. This ensures the Moshi upgrade from the previous commit (that was necessary due to the new Kotlin 1.9 metadata format) actually builds without any warnings. KSP should also theoretically be much faster for the overall build but i haven't analyzed this deeply. Surprisingly no language migrations needed as part of this movement (so far at least).
|
Hi @BenHenning, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
|
Hi @BenHenning, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
|
Hi @BenHenning, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
|
Hi @BenHenning, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Conflicts: WORKSPACE build_vars.bzl third_party/maven_install.json third_party/versions.bzl
This was 100% done in AntiGravity using Gemini models. Note that this is downgrading rules_kotlin & related compiler to 1.9.x because there's a fundamental compatibility problem we run into: we can't combine a 2.x compiler with 1.9.x stdlib without one version violations (hence the Proguard rules), and rules_kotlin 2.x doesn't support using a 1.9.x compiler. The hope is that we can proceed with the Bazel migration as-is with rules_kotlin 1.9.x but I am skeptical.
|
PTAL @adhiamboperes. I still need to self review the PR code, but I don't expect many changes. I think CI was passing locally but the actions runs seem to be running out of memory very easily. I'm not certain this is caused by my PRs or if it's just a consequence of continuing GitHub instability. If my PRs are going to make CI worse then I'll probably need to dig further into possible fixes (but maybe after they're merged so that we can prioritize getting the signals work done). It may also be worth prioritizing getting Bazel 7 merged in and then working on optimizations (or even continuing to latest Bazel via bzlmod because I'm assuming each jump will introduce new optimization challenges, regardless, so it's probably not worth overfixing on a specific version yet). |
adhiamboperes
left a comment
There was a problem hiding this comment.
Thanks @BenHenning!
I have left some comments inline.
Also re-ran the tests once and they failed, so I have retried them again. PTAL when they complete.
| maven_dependency { | ||
| artifact_name: "com.squareup.moshi:moshi:1.13.0" | ||
| artifact_name: "com.squareup.moshi:moshi:1.15.0" | ||
| artifact_version: "1.13.0" |
There was a problem hiding this comment.
The name changed to 1.15 but reported version is still 1.13.0. Ditto ln1680 and 1691.
| artifact_name: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0" | ||
| artifact_version: "1.6.21" |
Explanation
Fixes #6228
Fixes part of #6233
Written by AI and edited by @BenHenning
This PR upgrades the repository's Kotlin compiler & language version from
1.6.10(1.6) to1.9.0(1.9), upgradesrules_kotlinfromv1.7.1to1.9.2, and migrates Moshi code generation fromjava_plugin(kapt) tokt_ksp_plugin(KSP) while keeping the build on Bazel6.5.0.Per #6021, migrating to Bazel
7.x+(#6233) is required to restore Android Studio support (since the rewritten Bazel plugin required by Android Studio Otter and newer drops support for Bazel6.x). Because each layer of the Bazel 7 upgrade carries substantial build & runtime risk, the migration is staged across a chain of PRs so each piece can land and settle independently: #6234 upgrades the core Java, proto, JVM, and initialrules_androiddependencies on Bazel6.5.0, this PR (#6235) isolates the Kotlin1.9&rules_kotlintoolchain migration (which is also needed by the newer AndroidX, databinding, and Robolectric dependencies in #6237 that compile against Kotlin1.8+/1.9metadata), #6236 migrates production shrinking from Proguard to R8, and #6237 upgrades Bazel itself to7.7.1.Specific toolchain, KSP, and dependency changes to note:
build_vars.bzlupdatesKOTLIN_COMPILER_VERSIONfrom"1.6.10"to"1.9.0"andKOTLIN_LANGUAGE_VERSIONfrom"1.6"to"1.9"(withAndroidBuildSdkPropertiesTestupdated accordingly), andthird_party/versions.bzl&WORKSPACEupgraderules_kotlinfromv1.7.1to1.9.2(updating itshttp_archiveURL to the new release tarball format and deletingtools/kotlin/remove_processor_duplicates.patchplus itsexports_filesentry intools/kotlin/BUILD.bazel, since upstreamrules_kotlin1.8+already deduplicates annotation processor arguments viauniquify = True).rules_kotlinto2.1.3(which was explored in earlier commits on this branch),rules_kotlinis pinned to1.9.2(1.9.0and1.9.1have akt_android_librarytestonlypropagation bug) withkotlinc_versionexplicitly pinned to1.9.0andksp_versionpinned to1.9.0-1.0.12inWORKSPACE. This is due to a three-way constraint inrules_kotlin:rules_kotlinunconditionally injects thekotlin-stdlibbundled in itscompiler_releasearchive into targetJavaInfodependencies regardless oflanguage_versionorinclude_stdlibs, so pairing a2.1.xcompiler with Maven'skotlin-stdlib1.9.0causes split-stdlib one-definition violations duringsinglejarmerging and//:oppia_alphaProguard shrinking (where inner classes removed in2.1.xremain orphaned from1.9.0), whilerules_kotlin2.xcannot execute a1.9.xcompiler (failing both in_get_capability_templaterepository evaluation and at compile time with aNoSuchMethodErrorinBazelK2JVMCompilerdue toCLICompiler.parseArgumentssignature changes in Kotlin2.0). Keepingrules_kotlin,kotlinc, and Maven'skotlin-stdlibaligned on1.9.xavoids any split-stdlib Proguard workarounds here, though I'm a bit skeptical whetherrules_kotlin1.9.2will work all the way through the Bazel 7 upgrade in Fix #6233: Migrate to Bazel 7 [Blocked: #6236] #6237 as-is (alongsiderules_kotlin_bazel7_fixes.patch) or whether Fix #6233: Migrate to Bazel 7 [Blocked: #6236] #6237 will require bumpingrules_kotlinto1.9.6or migrating to Kotlin2.x.com.squareup.moshi:moshi-kotlinandcom.squareup.moshi:moshi-kotlin-codegenare upgraded from1.13.0to1.15.0so Moshi codegen can read Kotlin1.9.0metadata. Because Moshi1.15.0deprecates kapt codegen (which fails the build under warnings-as-errors),//tools:moshi_annotation_processor_pluginintools/BUILD.bazelis converted from ajava_plugin(JsonClassCodegenProcessor) to akt_ksp_plugin(JsonClassSymbolProcessorProvider), and//third_party:moshiinthird_party/BUILD.bazelis changed fromjava_librarytokt_jvm_library. Sincekt_jvm_librarydoes not supportexported_pluginsforkt_ksp_plugin, targets that use@JsonClass(generateAdapter = true)now declareplugins = ["//tools:moshi_annotation_processor_plugin"]directly (e.g.//data/src/main/java/org/oppia/android/data/backends/gae/model,//scripts/src/java/org/oppia/android/scripts/maven/model,//scripts/src/java/org/oppia/android/scripts/release:google_vertex_ai_client, and several GAE test & release model targets). To support KSP plugins indatalayer tests (pulled forward from Fix #6233: Migrate to Bazel 7 [Blocked: #6236] #6237 forRetrofitModuleTest),oppia_android_test.bzlthreads apluginsparameter throughoppia_android_test, anddata/data_test.bzlattaches//tools:moshi_annotation_processor_plugintodata_test.third_party/versions.bzluse the oldest releases compatible with Kotlin1.9.0metadata and compiler APIs:org.jetbrains.kotlin:kotlin-stdlib-jdk8(1.6.10->1.9.0),org.jetbrains.kotlin:kotlin-compiler-embeddable(1.5.0->1.9.0), andorg.jetbrains.kotlin:kotlin-reflect(1.3.41->1.9.0) are updated to matchKOTLIN_COMPILER_VERSION.daggeris upgraded from2.41to2.46(the oldest release bundlingkotlinx-metadata-jvm0.6.0for Kotlin1.9.0metadata support).androidx.compose.compiler:compileris upgraded from1.1.1to1.5.0(the oldest Compose compiler compatible withkotlinc1.9.0, while keeping the Compose UI/foundation/material/runtime libraries at1.1.1).third_party/maven_install.jsonand regeneratingscripts/assets/maven_dependencies.textprotorecords these direct bumps along with their transitive dependency shifts and removes the obsoleteconflict_resolutionoverrides forkotlin-reflect:1.3.41andkotlin-stdlib-jdk8:1.6.10.I've verified these changes locally on Bazel
6.5.0by building//:oppia_devand//:oppia_alpha(including Proguard6.2.2shrinking/obfuscation), running all static checks (bash scripts/static_checks.sh), full Android Lint (//scripts:android_lint_check), and affected unit & Robolectric tests.Essential Checklist
Disclosure of LLM Usage
1.9upgrade (b844641) and KSP migration (8d4d4a3) commits through extensive back-and-forth prompting, and AntiGravity (using Gemini models) was used for the post-merge build stabilization, dependency minimization, andrules_kotlin1.9.2downgrade (cd1fada). Separately, this PR description was drafted with an AI agent from the branch diff and my answers to its questions, and then reviewed and edited by me.For UI-specific PRs only
N/A -- Build & dependency infrastructure-only change that shouldn't impact the UI or UX of the app (outside of bumping the Compose compiler plugin for compatibility with Kotlin
1.9.0but that should be a functional no-op even if it could risk introducing new bugs).