[英]How do you set up a Kotlin multi-platform build?
I'd like to build the same kotlin source code into javascript and java (android). 我想将相同的kotlin源代码构建为javascript和java(android)。 Is there a standard way to achieve this? 是否有实现此目的的标准方法?
Official multi-platform support for Kotlin hasn't been released yet. 尚未发布对Kotlin的官方多平台支持。 If you'd like to stay up to date on it I reccomend following the #multiplatform channel on the Kotlin Slack . 如果您想了解最新消息,建议您遵循Kotlin Slack上的#multiplatform频道 。
common
, android-specific
and js-specific
. 创建3个新的Gradle模块: common
, android-specific
和js-specific
。 Make sure they are added as module to your main module 确保将它们作为模块添加到您的主模块中 android-specific
and js-specific
) 按下一步,然后完成(并针对android-specific
和js-specific
重复此操作) settings.gradle
from common
, and the other 2 modules as you aren't going to need them 从common
和其他2个模块中删除settings.gradle
,因为您将不需要它们 Make sure these 3 new modules are added to the main "parent" module's settings.gradle
. 确保将这3个新模块添加到主“父”模块的settings.gradle
。 It should look more less like this: 它看起来应该更像这样:
rootProject.name = 'parent' include ':common' include ':android-specific' include ':js-specific'
common
's module dependency ( build.gradle
file, line 24 for me ) from org.jetbrains.kotlin:kotlin-stdlib-jre8
to org.jetbrains.kotlin:kotlin-stdlib
so it's not platform-specific. 从org.jetbrains.kotlin:kotlin-stdlib-jre8
到org.jetbrains.kotlin:kotlin-stdlib
编辑common
的模块依赖项( build.gradle
文件,第24行,对我来说 ),因此它不是特定于平台的。 The gradle config should also work without IntelliJ (or Android Studio) but I didn't test it gradle配置也可以在没有IntelliJ(或Android Studio)的情况下使用,但我没有对其进行测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.