https://kotlinlang.org logo
Title
g

gaetan

07/14/2017, 2:54 PM
I don’t find any kotlin-dsl sample on javascript compilation. When can I found the options?
b

bashor

07/17/2017, 3:02 PM
@gaetan do you meant a sample of Korlin JS project using gradle kotlin dsl?
g

gaetan

07/17/2017, 3:51 PM
Yes. Sorry that wasn’t very clear.
b

bashor

07/17/2017, 7:17 PM
I don’t know how to write it now simpler than
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile

buildscript {
    repositories {
        jcenter()
    }

    val kotlinVersion by extra { "1.1.3-2" }

    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
    }
}

apply {
    plugin("kotlin2js")
}

repositories {
    jcenter()
}

dependencies {
    "compile"(kotlin("stdlib-js"))
}

val compileKotlin2Js: Kotlin2JsCompile by tasks

compileKotlin2Js.kotlinOptions {
    sourceMap = true
}

//tasks.withType<Kotlin2JsCompile> {
//    kotlinOptions.sourceMap = true
//}
//
//tasks.getByName("compileKotlin2Js") {
//    this as Kotlin2JsCompile
//    kotlinOptions.sourceMap = true
//}
1
Maybe GK DSL experts can help us 😉 cc @ilya.chernikov
i

ilya.chernikov

07/17/2017, 7:34 PM
I think that GK DSL authors are better experts than me. cc: @bamboo
👌 1
g

gaetan

07/18/2017, 4:31 PM
The page https://kotlinlang.org/docs/reference/using-gradle.html indicates that plugin can be applied using the Gradle plugins DSL.
plugins {
    id "org.jetbrains.kotlin.jvm" version "<version to use>"
}
b

bashor

07/18/2017, 4:49 PM
gradle plugin for kotlin js is not available in plugin repo
g

gaetan

07/18/2017, 5:15 PM
I’m not sure to understand: it’s not possible to use gradle for kotlin js?
b

bashor

07/18/2017, 5:17 PM
it means that you can’t use now mentioned above syntax for kotlin js
plugins {
    id ...
}
g

gaetan

07/18/2017, 5:25 PM
It’s frightening like sorcery. «You can use only that syntax with kotlin.jvm» means the underlying stuff depends on the syntax. Which also means: «you cannot rely on previous documentation because the underlying objects are not the same». My personal translation is «go away, now or it will cost a lot of time». Am I wrong?
The maven version seems a lot more verbose but also a lot more stable.
b

bashor

07/18/2017, 5:44 PM
Where from the citations?
what it doesn’t work for js now doesn’t mean that it will now work. I don’t work on this part of code but I think underlying objects was not changed so much.
g

gaetan

07/18/2017, 5:53 PM
Maybe it’s not more stable but more understandable. When I read the doc:
To target the JVM, the Kotlin plugin needs to be applied:

apply plugin: "kotlin"
Or, starting with Kotlin 1.1.1, the plugin can be applied using the Gradle plugins DSL:

plugins {
    id "org.jetbrains.kotlin.jvm" version "<version to use>"
}
I understand “there is just one plugin” with 2 ways of applying it.
But from what you say, it’s not that.
b

bashor

07/18/2017, 5:55 PM
Actually, right now the difference is only how to apply plugin. Other things will be more or less the same. I.e. I don’t see a simple way to configure a compiler even for JVM, but maybe for JVM it’s not required often.
g

gaetan

07/18/2017, 5:56 PM
So if it’s the same plugin it should work also for the js one.
That is my problem: you know some stuff that are really difficult for me to know (the jvm plugin works with the latest syntax, but not the js one). I fear to loose lot of time because of information I don’t have.