Kotlin ABI compatibility checking#108
Open
sugarmanz wants to merge 8 commits into
Open
Conversation
Introduce `abi_dump`, `abi_check_test`, and `abi_update` rules plus an `abi`
macro that wires them together for any kt_jvm_library-style target, mirroring
the JetBrains Binary Compatibility Validator Gradle plugin. The dump itself is
produced by a Clikt-based CLI (`kotlin/private/abi/AbiCli.kt`) wrapping the
BCV library's JVM API.
Wrappers `kt_jvm` and `kt_android` opt in via `api_file`; the default
`api/{name}.api` matches BCV's Gradle layout. The check rule auto-stubs an
empty placeholder when the golden file is missing so first-run bootstrap via
`abi-update-all` doesn't hit a load-time error.
`abi_update_all` is a `bazel run`-able launcher that uses `bazel cquery` to
discover every `abi_update` target in the workspace, sidestepping the
limitations of aspect-based aggregation. The nested `bazel` calls work
because `bazel run` `exec`s the launcher before the inner invocations.
Also adds `//private:maven.bzl` exposing a thin `artifact()` helper pinned
to `rules_player_maven`, and migrates existing `@rules_player_maven//:...`
references in `distribution/BUILD` to use it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract the workspace-discovery shell launcher used by `abi_update_all` into `//internal/private:run_all_of_kind.sh`. The script now takes `--kind`, `--mode`, and `--scope` so any rule kind can be enumerated and invoked. `abi_update_all` becomes a thin macro wrapping the shared script with `--kind abi_update`. A new sibling macro `lint_fix_all` does the same for `--kind ktlint_fix`, giving a single `bazel run :lint-fix-all` entry point for workspace-wide lint fixing. The label is re-exported as `RUN_ALL_OF_KIND` from `//internal:defs.bzl` so consumer macros can reference it via a stable path next to the script. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Promote `scope_name.bzl` from `//kotlin/private` to `//internal/private`
since it's a generic naming helper used across rule families, not Kotlin-
specific. Re-export it from `//internal:defs.bzl` so consumers load the
function through the public defs surface alongside `stamp` and
`RUN_ALL_OF_KIND`.
All five callers in `kotlin/private/` (abi, distribution, lint, and the
two library-and-test wrappers) now `load("//internal:defs.bzl",
"scope_name")`. The `bzl_library` graph follows the same path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement rules for testing, building, and updating Kotlin binary compatibility for player-ui/player#155.
Also:
Release notes
Kotlin ABI compatibility checking
New first-class support for tracking the public ABI of Kotlin libraries, mirroring JetBrains' Binary Compatibility Validator Gradle plugin.
Enabled by default on
kt_jvmandkt_android. Each library gains three sibling targets that maintain a checked-inapi/{name}.apigolden file:Generated targets:
:my-lib-abi-dump—bazel buildemits a canonical BCV-format.apidump:my-lib-abi-check—bazel testdiffs the dump against the golden, failing with a unified diff on mismatch:my-lib-abi-update—bazel runregenerates the golden file in the source treeFirst-time bootstrap is friction-free: if the golden file doesn't exist yet, an empty placeholder is auto-stubbed so the first
abi-checkproduces a clean "everything is new" diff instead of a load-time error. Run:my-lib-abi-updateto materialize the real file.Advanced filtering matches BCV's Gradle plugin — opt declarations in/out via package, class, or annotation:
Workspace-level batch runners
Two new macros enumerate every matching target in the workspace at
bazel runtime and invoke each in turn — nodepslist to maintain:Discovery is automatic: any newly-introduced
abi_updateorktlint_fixtarget is picked up on the next run.