I need a tool to check if I break binary compatibi...
# library-development
m
I need a tool to check if I break binary compatibility in my library. I stumbled across binary-compatibility-validator, and it looks promising. However, it seems like it depends on Gradle, and I use Maven as my build system. Is it possible to use from Maven (possibly with Maven exec if there is not proper Maven plugin)? Or is there some other similar tool which works from Maven?
e
unfortunately it looks to be quite tied to Gradle
m
Yeah, that was me.
e
in principle, everything in the kotlinx.api.validation package appears to only depend on ASM and kotlin-metadata-jvm, so if you set up the classpath appropriately and re-implement the logic of kotlinx.validation.AbiBuildWorker outside of Gradle, you might be able to build your own CLI
m
Yes, I am trying to do that.
Or not really a proper CLI, but a way to invoke it from Maven.
a
if you're only interested in validating JVM code, then it's quite simple to treat the existing BCV as a library and invoke it manually. I wrote a custom Gradle plugin (because the existing BCV doesn't follow Gradle best practices), and it uses the existing BCV as a library. Try taking a look at the code here: https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu/blob/94675fe0c65d7539923836002aa03c91ddcd7130/modules/bcv-gradle-plugin/src/main/kotlin/workers/BCVSignaturesWorker.kt#L68-L106
m
Yes, I am using the library module (which Jetbrains claim doesn't exist, but I am using it anyway!), and it works if you add a few missing dependencies.
a
That's not a library module, that's the Gradle plugin. You can certainly use it, but it will include unnecessary code and dependencies (potentially the Gradle API?), but that probably won't be a problem for a Maven plugin
e
it has code that uses the Gradle API, but the dependency isn't there (as far as Maven is concerned), so as long as you don't touch classes that would fail to load in the absence of Gradle, it's blob no problem
m
Seems like if you only use the
kotlinx.validation.api
package, you don't get any Gradle dependencies. That package can be considered a library, it's just not released as such.
kodee happy 2
🎉 1
It seems to me that this tool detects all changes to an API, not only breaking changes, and you have to manually judge whether the changes are breaking. Right? Or did I some mistake in the Maven plugin?
b
Correct
e
Correct, it lists the complete API, so you would have to manually determine whether something is breaking or not (typically deleted/changed rows).
m
...or added rows to interfaces?
👍 1
Added rows to interfaces (or abstract classes) is actually "in between": https://wiki.openjdk.org/display/csr/Kinds+of+Compatibility#KindsofCompatibility-BinaryCompatibility
a
there's a good guide for maintaining backwards compatibility for Kotlin libs, in case it helps https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html