Search code examples
kotlingradlekotlin-multiplatform

Is there a way how to add Kotlin Multiplatform target to a published KMP library which does not contain the target artifact?


I am building internal Kotlin Multiplatform (KMP) library which has a dependency to a published KMP library. The published library does not have support for the target I need, in my case it is mingwX64 target, but that should not be important from general point of view.

The published library supports following targets: jvm, mac/ios targets, linuxX64, android

When I add the public library as a commonMain dependency to my build.gradle.kts file of my multiplatform internal library (which supports also mingwX64), the gradle is complaining, that it could not resolve the mingwX64 artifact of the library, as expected, because the published library doesn't support it, therefore there cannot exist published artifact for the platform.

Is there any other way how to add the target I want to support than forking the project with missing target and adding the support for the target this way?

I would like to be able to provide a support through my internal library without touching the public library directly (without forking the source code and building the code myself), which means provide all the expect/actual implementations and build the code for a new targeted platform.


Solution

  • I think this is not possible at the moment, but I can't find the reference to the corresponding YouTrack issue.

    I guess your best bet would be to contribute the new target to the library (if it's open source).

    Another option would be to write a wrapper with a similar interface and use the library as an actual implementation in a source set covering all its targets, and use your own custom code in a separate source set for the extra target(s).