First, because like me, you are too lazy to read the complete Gradle stuffs, and second, because if you read Kotlinlang website, dedicated sections related to this subject, it will not work :/ .
TL; TR, here is the build.gradle file sections modified for Kotlin2Js to be alive:
buildscript { ext.kotlin_version = "1.1.4-3"//'${kotlinVersion}' ext.web_dir = "grails-app/assets/javascripts/kt"
[. . .]dependencies {} [. . .] apply plugin: 'kotlin2js' [. . .] dependencies { [. . .] compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"}classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"classpath "org.grails:grails-gradle-plugin:$grailsVersion"classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"classpath "org.grails:grails-gradle-plugin:$grailsVersion"[. . .]
assets {[. . .] // Nothing to change
} /* Kotlin javascript section +++ */ clean.doFirst() { delete("${web_dir}") }build.doLast() {
// Copy kotlin.js and kotlin-meta.js from jar into web directory configurations.compile.each { File file ->
configurations.compile.each { File file ->copy {includeEmptyDirs = false from zipTree(file.absolutePath)into "${projectDir}/${web_dir}"include "*.js"} } } compileKotlin2Js.doLast() { copy { includeEmptyDirs = false from new File("build/classes/main")include "*.js"into "${web_dir}" }}/* Kotlin javascript section --- */ bootRun { jvmArgs('-Xmx3064m', '-Dspring.output.ansi.enabled=always', '-server') } runCommand { jvmArgs('-Xmx8064m', '-Dspring.output.ansi.enabled=always', '-server') }
}
Assets plugin will compact the JavaScript code as expected.
If you are feed up with Angular
You will benefit almost simple Gradle integration (which is not yet available in Dart), IDE more efficient auto-completion, with real static analysis (AngularTS massive JSON uses, makes it more difficult).
Aucun commentaire:
Enregistrer un commentaire