Any updates on implement variants? I want to have...
# amper
s
Any updates on implement variants? I want to have a common source set, and have 2 different jvm implementation, is it possible to achieve this in current version of amper?
a
Variants are still not fully supported in Gradle-based and not supported at all in the standalone version. Could you share your use case? Would the old-school modularization be a reasonable solution?
s
I think different variants are just same module, they expose exactly api
Like Kotlin Multiplatform, same api, implement on different platform. Btw, I think skiko uses some sort of variant, https://github.com/JetBrains/skiko/tree/master/skiko/src awtMain, jvmMain, is both jvm. Is it possible to define a platform multiple times with different name in amper? like in gradle https://github.com/JetBrains/skiko/blob/master/skiko/build.gradle.kts#L50 This gives us something like variant.
a
I see what you mean. Amper build variants are supposed to be slightly different versions of the same product, E.g. Debug and release, or Free and Paid. They are not designed to produce different product out of the same module. What would be your case? What’d the difference between the two jvm implementations?
s
The one I'm currently working on is implement same set of API with different backend (CPU/GPU). In this case, like what you said,they technically have the same API, but slightly different, for example, GPU initialization requires extra work. It is pretty common for different implementation to have something slightly different.
Right now, with gradle I can use jvm("gpu") jvm("cpu"), will something like this supported in amper?
a
I see, currently, it’s not possible. Build variants could technically unlock such a use case, when you define two variants with CPU and GPU implementations. Though, I’d suggest to consider other options, such as dependency injection, or plain if/else logic. Variants and the `expect`/`actual` mechanism are a rather advanced use cases and their main application stays multi-platform code.
1