gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 434 forks source link

Unresolved reference: compileKotlin2Js in Intellij Idea 2018.3 #1266

Closed pankajbsn closed 5 years ago

pankajbsn commented 5 years ago

In Intellij Idea 2018.3 when I create a new KotlinJS gradle project, with kotlin-dsl, In build.gradle.kts it gives me error that "Unresolved reference: compileKotlin2Js". However, when I import hello-js sample project in same IDE, it works fine. I cant figure out what is the difference. I am using the same build.gradle.js as from hello-js sample project.

Expected Behavior

Current Behavior

Context

Steps to Reproduce (for bugs)

Your Environment

pankajbsn commented 5 years ago

Changing gradle version from 4.10.2 to 5.0 resolved the issue. After that from command line it worked but Intellij Idea was still giving error. In IDE --> Settings --> Gradle --> Use Local Gradle distribution. And then I set Gradle 5 as home. Then it stopped giving error in IDE as well. Although, I don't understand, why it was not working with Gradle 4.10.2.

wuairc commented 5 years ago

Changing gradle version from 4.10.2 to 5.0 resolved the issue. After that from command line it worked but Intellij Idea was still giving error. In IDE --> Settings --> Gradle --> Use Local Gradle distribution. And then I set Gradle 5 as home. Then it stopped giving error in IDE as well. Although, I don't understand, why it was not working with Gradle 4.10.2.

It seems Kotlin plugin in IDEA 2018.3 is broken, upgrade gradle to 5.0 worked for me

eskatos commented 5 years ago

Closing as solved

dvekeman commented 5 years ago

For those who cannot upgrade to Gradle 5.x (e.g. due to a bug in the kotlin-frontend-plugin: https://github.com/Kotlin/kotlin-frontend-plugin/issues/122). There is a workaround for Gradle 4.10.3:

tasks {
    "compileKotlin2Js"(Kotlin2JsCompile::class) {
        kotlinOptions {
            outputFile = ...
            sourceMap = true
        }
    }
}