Best practice for multi target project

There is a best practice (or example project) to create a multi target project?


I need to write a simple library to perform HTTP GET requests for both JVM and Javascript.

I should create a single project with mixed code? How?

I need to create two project for implementation and a separate one with shared code?


1 Like

Full support for multi-target projects is planned for post-release Kotlin 1.1.x updates. When it’s done, we’ll provide documentation, examples and the IDE support required for working with such projects.

1 Like

Please tell you are bringing ifdef. And then full compile time macro support :smiley:
Looks like js targeted code can’t even use kapt for any compile time code generation.

No, we aren’t bringing any macro support or JS compile-time code generation; we believe that our design solves the most common problems for multi-platform projects without requiring either of those features.

My guess about your design would be “dotnet standard”(interface standard + platform implementations) like?
Will it force user/library code to do separate interface/implementation builds for any advanced and platform specific features?

I’d just be happy when I can create a “shared code” library that contains code for both platforms (that is valid on both) that is then used in target specific user modules. The main issue in this is with intellij (it doesn’t support multi-targeting and gets mightily confused if you include one directory as source for multiple modules - either directly or through symbolic links), not with Kotlin itself (even gradle can be made to deal with it reasonably easily)