kotlinpoet icon indicating copy to clipboard operation
kotlinpoet copied to clipboard

Restructure the project for multiplatform Kotlin

Open Egorand opened this issue 6 years ago • 7 comments

  • [x] Switch to Gradle (Maven not supported yet)
  • [ ] Create a common module and a platform module for JVM

Egorand avatar Dec 15 '17 23:12 Egorand

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...

Egorand avatar Dec 17 '17 11:12 Egorand

Are there any updates on this issue? Can we use the generated code in our KMM project?

tamimattafi avatar Feb 15 '22 14:02 tamimattafi

Yes, generated code is platform-agnostic by default. This issue was about making KotlinPoet itself multiplatform.

Egorand avatar Feb 15 '22 15:02 Egorand

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.

krzema12 avatar Apr 07 '23 07:04 krzema12

+1 to krzema12 if there is a rough list of remaining tasks, I'd like to see if I can contribute, too. @Egorand

thagikura avatar Jun 08 '23 12:06 thagikura

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.

JakeWharton avatar Jun 08 '23 13:06 JakeWharton

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

takahirom avatar Aug 04 '23 01:08 takahirom