https://kotlinlang.org logo
#library-development
Title
# library-development
z

Zach Klippenstein (he/him) [MOD]

02/10/2020, 3:31 PM
If you follow any official Kotlin projects (e.g. coroutines), you might have noticed diffs include files that contain what looks like pretty-printed class file data. JetBrains has a binary validator tool that they’ve been copy-pasting to a few of their libraries. They recently broke it out into a dedicated repo, and it’s published as a Gradle plugin on their bintray site! https://github.com/Kotlin/binary-compatibility-validator This tool generates a human-readable-ish dump of your public binary APIs and will fail your build if you make a breaking binary change without updating the dump. This tool is extremely useful for libraries that want to remain backwards-binary compatible, or just keep an eye on what their actual binary API is vs source API. It’s super easy to use too, just add the gradle plugin in your root
build.gradle
and run
./gradlew apiDump
to generate an initial dump.
project_name.api
files will be placed in an
api
directory beside your
src
directory in each sub-project.
👍 9
🤯 1
Here’s a sample PR that introduces the validator to a library I work on: https://github.com/square/workflow/pull/948
👍 1
This tool doesn’t seem to support android modules yet though, 👍 this issue to ask for support: https://github.com/Kotlin/binary-compatibility-validator/issues/4
e

elizarov

02/12/2020, 2:21 PM
Kudos to @Vsevolod Tolstopyatov [JB]
🙏 2
z

Zach Klippenstein (he/him) [MOD]

02/12/2020, 6:42 PM
3 Views