Skip to content

Fix #6229, part of #6233: Prepare for Bazel 7 upgrade - #6234

Open
BenHenning wants to merge 8 commits into
developfrom
prepare-for-bazel-7-upgrade
Open

BenHenning wants to merge 8 commits into
developfrom
prepare-for-bazel-7-upgrade

Conversation

@BenHenning

@BenHenning BenHenning commented Apr 20, 2026 •

Copy link
Copy Markdown
Member

Explanation

Fixes #6229
Fixes part of #6233

Written by AI and edited by @BenHenning

This PR upgrades key Bazel workspace & Maven dependencies to versions compatible with both Bazel 6.5.0 and Bazel 7.x, and introduces initial Starlark rules_android support while keeping the repository on Bazel 6.5.0.

Per #6021, Android Studio Otter and newer require a Bazel plugin rewrite that drops support for Bazel 6.x in favor of Bazel 7.x+. Building on the offline pre-fetching & build stability groundwork in #6164, this PR pulls forward the Bazel 6.5.0-compatible dependency and rule updates so each high-risk layer of the #6233 migration can land and settle independently ahead of migrating to Kotlin 1.9 & KSP (#6235), switching from Proguard to R8 (#6236), and upgrading Bazel itself to 7.7.1 (#6237).

Specific Bazel rule & toolchain changes to note (using versions that work together under Bazel 6.5.0 alongside our oppia_proto_api/protobuf & JDK setup while also falling within Bazel 7-compatible release lines and avoiding the Turbine JDK resolution failures hit with some other rule combinations during the #6021 investigation):

  • rules_java is upgraded from 5.3.5 to 7.3.1, and rules_proto is moved from pinned commit c0b62f2f46c85c16cb3b5e9e921f0d00e3101934 to release 7.1.0 (switching its http_archive to the release tarball).
  • rules_jvm_external (rules_jvm) is upgraded from 5.1 to 6.9 (also switching from a GitHub source zip to the release tarball).
  • rules_kotlin is upgraded from v1.7.1 to 2.1.3 (the final release supporting Bazel 6.x), updating kotlin_repositories() in WORKSPACE to use rules_kotlin's bundled compiler rather than pinning kotlinc 1.6.10 separately. To avoid coupling a full Kotlin language upgrade into this PR, build_vars.bzl replaces KOTLIN_COMPILER_VERSION with KOTLIN_LANGUAGE_VERSION = "1.6" for define_kt_toolchain in tools/kotlin/BUILD.bazel, and AndroidBuildSdkProperties & AndroidLintRunner (plus their unit tests) now read this language version directly instead of stripping the patch segment off a compiler version.
  • bazel_features (1.25.0) and rules_license (1.0.0) are added to WORKSPACE & third_party/versions.bzl to satisfy transitive repository dependencies required by the upgraded rule sets.
  • rules_android (0.1.1, the version compatible with Bazel 6.5.0) is introduced in WORKSPACE (android_sdk_repository), instrumentation/oppia_instrumentation_test.bzl (android_binary & android_instrumentation_test), and the BUILD.bazel files that directly invoke android_library or android_binary (e.g. app/BUILD.bazel, third_party/BUILD.bazel, and utility/BUILD.bazel). oppia_android_application.bzl and oppia_android_test.bzl remain on native.android_binary and native.android_local_test for now because migrating those central macros hit compatibility issues with rules_android 0.1.1 on Bazel 6.5.0 and requires rules_android 0.7.1 plus patches in Fix #6233: Migrate to Bazel 7 [Blocked: #6236] #6237. Since 0.1.1 largely delegates through to Bazel's built-in Android rules anyway, this partial migration is effectively a build no-op that sets up the @rules_android load pattern ahead of Fix #6228, part of #6233: Migrate to Kotlin 1.9 [Blocked: #6234] #6235 and Fix #6233: Migrate to Bazel 7 [Blocked: #6236] #6237.

Other Maven & build adjustments required by these upgrades (or cleaned up while repinning):

  • androidx.compose.compiler:compiler is bumped from 1.1.1 to 1.4.7 for compatibility with the newer Kotlin compiler bundled in rules_kotlin 2.1.3 (while keeping the Compose runtime/UI libraries at 1.1.1 and the Kotlin language level at 1.6).
  • Explicit :jar packaging suffixes are dropped from javax.annotation:javax.annotation-api, org.jetbrains.kotlin:kotlin-stdlib-jdk8, and org.jetbrains:annotations in third_party/versions.bzl as required by rules_jvm_external 6.9, updating the corresponding //third_party:* target references in app/BUILD.bazel and scripts/src/java/org/oppia/android/scripts/common/BUILD.bazel.
  • https://maven.fabric.io/public was removed from MAVEN_REPOSITORIES since it is defunct, and https://repo1.maven.org/maven2 was ordered ahead of https://maven.google.com (partially an attempt to improve 404 artifact errors but there's more work needed here in a future PR). Repinning third_party/maven_install.json also adds rules_jvm_external 6.9's "services" metadata block and picks up minor transitive shifts (org.bouncycastle 2.73.12 -> 2.73.13 and com.google.guava:guava in the lockfile, though Android builds still resolve Guava to 31.0.1-android via WORKSPACE's override_targets mapping to //third_party:com_google_guava_guava).
  • .bazelrc adds build --javacopt="-Xlint:-options" --host_javacopt="-Xlint:-options" to suppress unavoidable obsolete source/target option warnings under Bazel 6.x that would otherwise fail Java builds with -Werror enabled.
  • MathTagHandler adds @Deprecated and @Suppress("DeprecatedCallableAddReplaceWith") on LatexImageSpan's Drawable.getOpacity() override so the newer Kotlin compiler doesn't fail on an unannotated override of a Java-deprecated method under warnings-as-errors.

I've verified these changes locally on Bazel 6.5.0 via cursory app smoke testing (//:oppia_dev), release/Proguard builds (//:oppia_alpha), key Robolectric tests, and offline dependency pre-fetching (bazel sync & bazel fetch //...).

Essential Checklist

  • The PR title starts with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The explanation section above starts with "Fixes #bugnum: " (If this PR fixes part of an issue, use instead: "Fixes part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

Disclosure of LLM Usage

  • Did you use AI/LLMs when working on this PR? Yes
  • If yes, describe the extent AI was used: Gemini CLI generated the initial rules_android support commit (3cb9042bf), and Gemini was used briefly during the [BUG]: Android Studio Otter+ no longer compatible with project (must upgrade to Bazel 7.x+) [Blocked: #6233] #6021 investigation to double-check Bazel rule version compatibility ranges. All other commits on this branch (the main dependency & toolchain upgrades, merge conflict resolution, and Bazel lint fixes) and local verification were authored and verified entirely by me without AI (though much of these changes were pulled in from downstream PRs that were heavily AI generated as mentioned in those PRs). Separately, this PR description was drafted with an AI agent (using the a work-in-progress write-pr-description skill I'm building) 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 the newer Kotlin toolchain).

This upgrades key dependencies to prepare for the Bazel 7.x upgrade
without actually including that step. Cursory testing including with the
actual app has been done to verify things are working at a high-level.
I think this mainly just calls right through to the native rules so it's
basically a no-op other than setting precedent. Note that Gemini CLI
basically generated this entire commit though it will probably benefit
from some small tweaking later on.
@oppiabot

oppiabot Bot commented May 5, 2026

Copy link
Copy Markdown

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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you! If you're unsure how to reassign this PR to a reviewer, please make sure to review the wiki page that details the Guidance on submitting PRs.

@oppiabot oppiabot Bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 5, 2026
@adhiamboperes adhiamboperes removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 7, 2026
@oppiabot

oppiabot Bot commented May 14, 2026

Copy link
Copy Markdown

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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you! If you're unsure how to reassign this PR to a reviewer, please make sure to review the wiki page that details the Guidance on submitting PRs.

@oppiabot oppiabot Bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 14, 2026
@adhiamboperes adhiamboperes removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 19, 2026
@oppiabot

oppiabot Bot commented May 29, 2026

Copy link
Copy Markdown

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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you! If you're unsure how to reassign this PR to a reviewer, please make sure to review the wiki page that details the Guidance on submitting PRs.

@oppiabot oppiabot Bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label May 29, 2026
@oppiabot oppiabot Bot closed this Jun 5, 2026
Conflicts:
	WORKSPACE
	scripts/src/java/org/oppia/android/scripts/lint/AndroidLintRunner.kt
	third_party/maven_install.json
	third_party/versions.bzl
	tools/kotlin/BUILD.bazel
	utility/src/main/java/org/oppia/android/util/parser/html/MathTagHandler.kt
@BenHenning BenHenning reopened this Oct 23, 2026
@oppiabot oppiabot Bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Oct 23, 2026
It actually does need to stay (per a Gemini analysis using AntiGravity).
This entire commit was done by AntiGravity using Gemini models.
@BenHenning
BenHenning marked this pull request as ready for review October 31, 2026 03:05
@BenHenning
BenHenning requested review from a team as code owners October 31, 2026 03:05
@BenHenning

Copy link
Copy Markdown
Member Author

PTAL @adhiamboperes. Note that I still need to self review the file changes, double check offline builds, run the app, and update the PR description with the latest (and fix anything else that comes in from the next CI run). That being said, I strongly suspect this is very close to being ready to go and is definitely ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

@BenHenning this PR is being marked as draft because you are not assigned to referenced issue #6233 (or it does not exist). You may only fix issues that you are assigned to to help avoid multiple team members duplicating work on the same issue.

@github-actions
github-actions Bot marked this pull request as draft October 31, 2026 03:07
@BenHenning
BenHenning marked this pull request as ready for review November 3, 2026 01:53
@BenHenning

Copy link
Copy Markdown
Member Author

Forgot to self assign #6233 (thought it was, my bad).

I've pulled in the latest develop as well.

CI did fail before on CoverageRunnerTest and BazelClientTest due to the GH Actions runner running out of memory. I'm not certain this is a new issue for this PR so there may be some retries needed. If we see this pop up a lot we may need to consider mitigations (perhaps by moving those tests to their own buckets since they do tend to be quite hard on system resources from what I've seen).

@BenHenning BenHenning changed the title Fix part of #6233: Prepare for Bazel 7 upgrade Fix #6229, part of #6233: Prepare for Bazel 7 upgrade Nov 5, 2026

@adhiamboperes adhiamboperes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @BenHenning and apologies for the delay in review.

I found the diff to be LGTM, but I have concerns about the PR descriptions. It says that rules_kotlin moves to 2.1.3, the bundled compiler replaces the explicit pin, and Compose compiler becomes 1.4.7. The actual code retains rules_kotlin v1.7.1, Kotlin 1.6.10, and Compose compiler 1.1.1.

Also Suppress("WrongConstant") is removed from MathTagHandler, but it isn't explained why it is nolonger neccessary(it was previously added for suppression of a lint false positive.)

@BenHenning

Copy link
Copy Markdown
Member Author

Thanks @adhiamboperes. That's part of the PR description being slightly out of date and needing updating. Will take a look and at the handler (plus the rest of the code).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Migrate to the Starlark version of rules_android

2 participants