is it possible to use kotlin2js and kotlin in a gradle project?

kotlin · · 165 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Long story short:</p> <p>I&#39;m wanting to set up a spring boot project that I&#39;ll write the &#34;java&#34; code in kotlin and the javascript code in kotlinscript.</p> <p>The issue is that i can&#39;t use the kotlin and kotlin2js gradle plugins in my build.gradle. Seems like you can only use one or the other??</p> <p>Is there a way to be able to use both?</p> <hr/>**评论:**<br/><br/>SpacialCircumstances: <pre><p>The last version of IntelliJ includes the (experimental) option to set up a „common“ project. This creates three projects: The common one were you write all code that is not platform-dependent, and a JS and a JVM subproject. These projects contain platform-specific code and when they are built, the both contain the common code.</p> <p>Kotlinlang article here: <a href="https://kotlinlang.org/docs/reference/multiplatform.html" rel="nofollow">https://kotlinlang.org/docs/reference/multiplatform.html</a></p></pre>themraustin: <pre><p>Yes! You just need to create modules for:</p> <p>1) The common code (code that will be used in both the JS and Java programs)</p> <p>2) The JS code</p> <p>3) The Java code</p> <p><a href="https://github.com/MarcinMoskala/KotlinAcademyApp" rel="nofollow">Check out this repo</a>, it has a good structure on how to write the gradle scripts for each module.</p></pre>Stannu: <pre><p>You should split up your project into independent modules, which compile separately, each with their own Gradle configuration. This should be possible with Gradle, since it&#39;s a common thing to have slave projects with Maven and Gradle is a newer technology afaik.</p></pre>webdevnick22: <pre><p>yea i see what you mean. basically have a gradle subproject strictly for my javascript and another for the backend code. i&#39;ll do it if i have to but that kind of sucks. i&#39;d rather have it in one project. i feel like putting all of my javascript code in a subproject is overkill. not to mention i might have problems with file/variable name inferences.</p></pre>Stannu: <pre><p>Perhaps there is a better solution to this, I just wrote that I would do becaue I know this is a common practice, but again I am not an expert and it would help to hear from someone who is a Gradle guru or so.</p></pre>
165 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet