kotlinpoet
kotlinpoet copied to clipboard
Restructure the project for multiplatform Kotlin
- [x] Switch to Gradle (Maven not supported yet)
- [ ] Create a common module and a platform module for JVM
I'm preparing a POC, want to implement a few more use cases and will push. Looks like we'll have to give up on truth
for assertions to move tests to the common module...
Are there any updates on this issue? Can we use the generated code in our KMM project?
Yes, generated code is platform-agnostic by default. This issue was about making KotlinPoet itself multiplatform.
What's the status of this request?
I have an use case where I'd like to host my tool using KotlinPoet somewhere. JVM hosting, well, costs money, and I thought of using Kotlin/JS. KotlinPoet is one of the problematic dependencies because it's JVM-only.
If the topic is well explored, I'd be grateful for a rough list of items to address to make this library multiplatform. I may have a chance to contribute.
+1 to krzema12 if there is a rough list of remaining tasks, I'd like to see if I can contribute, too. @Egorand
The biggest inhibitor to this is the lack of default implementations in expect
classes. Because of the API design mixing common things with JVM-specific things, it's a gigantic pain in the ass to maintain effectively four copies of the API: the expect, the JVM actual facade, the non-JVM actual facade, and the real common implementations. It's not impossible to do this change without implementations inside expects, but it's certainly annoying.
I've made an attempt to address the issue of restructuring the project for multiplatform Kotlin. I have transitioned to using the Multiplatform plugin along with JVM configuration.
Please have a look at the changes. If you find them unnecessary or not aligned with your plans for the project, feel free to close this. https://github.com/square/kotlinpoet/pull/1654