This question has nothing to do with Kotlin multiplatform (Kotlin MPP) in that sense that from gradle point of view, Kotlin MPP configuration is just a particular case of multivariant build. So, imagine I want to redefine particular variant of dependency, for instance, I want to have a javascript module redefined. This approach works perfectly well:
substitute(module("org.shabunc.demo:lib-js")).using(project(":lib-js")) However it works because I know that for a common dependency "org.shabunc.demo" the "org.shabunc.demo-js" corresponds to the js variant of dependency.
I've decided to experiment with more advanced approach where I'm redefining the variant dependency, and I've tried to do something like this:
val kotlinPlatformTypeAttr = Attribute.of("org.jetbrains.kotlin.platform.type", KotlinPlatformType::class.java) ... substitute(variant(module("org.shabunc.demo:lib")) { attributes { attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "kotlin-api")) attribute(kotlinPlatformTypeAttr, KotlinPlatformType.js) } }).using(variant(project(":lib-js")) { attributes { attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "kotlin-api")) attribute(kotlinPlatformTypeAttr, KotlinPlatformType.js) } }) However this not working as expected, the compileKotlinMetadata is not resolving any entity defined in a common part of org.shabunc.demo:lib
My question is pretty straightforward: How can I redefine specific variant of Kotlin MPP dependency without relying on its name rather than on the name of common dependency?
https://stackoverflow.com/questions/66556610/how-to-substitute-dependency-for-a-specific-variant-of-kotlin-mpp-dependency-via March 10, 2021 at 08:17AM
没有评论:
发表评论