https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
g

Grantas33

04/09/2021, 1:45 PM
Hey. Are the any best practices of porting an existing jvm library (that you do not own) to mpp? Should you: 1. Fork the jvm lib repo and split the code into jvm/common modules. Code your own platform-specific implementation in other platform (e.g. js) for code that could not be extracted to common. 2. Create a new mpp project. Depend on the jvm lib in the jvm module and wrap all of the jvm-specific lib functions/classes in your own wrapper functions/classes. Extract jvm lib common code to common module. Code your own platform-specific implementation in other platform (e.g. js). 3. Create a new mpp project. Depend on the jvm lib in the jvm module and wrap all of the functions/classes in your own wrapper functions/classes. This way common module will only contain code with
expect
keywords. Code your own platform-specific implementation /copy paste common implementation from jvm lib in other platform (e.g. js). I feel like option 1 is the cleanest, option 3 should allow for easiest updates whenever original jvm lib is updated and option 2 is the most balanced. What do you think?
r

russhwolf

04/09/2021, 2:40 PM
This is definitely an "it depends" question. I think the big decision point is, do you want to use the original lib or fork it? And that will depend on a ton of factors, for example how actively it's being updated, what similar APIs exist on other platforms that you can make use of, how much useful common logic you can extract, etc
2 Views