Kotlin / binary-compatibility-validator

Public API management tool
Apache License 2.0
800 stars 59 forks source link

Add option to always generate platform specific folders #174

Open vRallev opened 8 months ago

vRallev commented 8 months ago

In our Kotlin Multiplatform project we use two JVM targets (Android and desktop), therefore this plugin will use two different folders for the API dumps: api/android and api/desktop. However, in CI we disable the desktop target and only Android is present. The apiCheck then will fail, because it doesn't look in the right directory for the dump. The code is here.

To avoid the issue, either an option to always us the platform specific folder no matter how many JVM targets would work, or as an alternative an option to disable targets, e.g. we'd disable desktop and only use Android.

fzhinkin commented 8 months ago

@vRallev how exactly do you disable the second target for the CI? Or maybe you have a small reproducer already?

vRallev commented 8 months ago

I've attached a sample project. To disable a target I simply don't configure it. The sample has a flag in build.gradle.kts:

val desktopEnabled = false

Depending on this flag the apiCheck will fail or be successful.

KotlinProject.zip

fzhinkin commented 8 months ago

Thanks for the reproducer!

To avoid the issue, either an option to always us the platform specific folder no matter how many JVM targets would work, or as an alternative an option to disable targets, e.g. we'd disable desktop and only use Android.

Just to explore possible solutions: would an option to use flat dump files layout (like api/<moduleName>.android.api, api/<moduleName>.desktop.api) work for you?

vRallev commented 8 months ago

Yes, it would. The important piece here is that the output path and file name must stay consistent and not depend on how many JVM targets are there, so it shouldn't switch between <moduleName>.android.api and <moduleName>.api.