Best practice for multi target project


#1

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

Example:

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?

Thanks.


#2

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.


#3

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.


#4

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.


#5

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?


#6

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)