[英]How to create a library in Kotlin and use it from projects that target javascript or java?
I am looking at how I can create a common library that is used by both front-end and back-end codebases. 我正在研究如何创建前端和后端代码库都可以使用的公共库。 I'd like to be able to create a library that is written purely in Kotlin, compile it, and register said artifact(s) to be imported as dependencies from both js (using npm) and kotlin-java (using maven).
我希望能够创建一个纯粹用Kotlin编写的库,对其进行编译,然后注册要从js(使用npm)和kotlin-java(使用maven)作为依赖项导入的工件。 Is this a workflow that is supported or possible?
这是受支持或可能的工作流程吗? If so, what are the approaches to doing so?
如果是这样,这样做的方法是什么?
When using Gradle instead of using compile ...kotlin-stdlib-jre8
(or any other jre
) use compile ...kotlin-stdlib
. 当使用Gradle而不是使用
compile ...kotlin-stdlib-jre8
(或任何其他jre
)时,请使用compile ...kotlin-stdlib
。 This should be enough though remember not to use Java-only features (such as most of the reflection features) as they won't work when using JavaScript 这应该足够了,但请记住不要使用仅Java功能(例如大多数反射功能),因为在使用JavaScript时它们将不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.