kotlin-frontend-plugin icon indicating copy to clipboard operation
kotlin-frontend-plugin copied to clipboard

build.gradle.kts: Unresolved reference: compile

Open BorzdeG opened this issue 7 years ago • 5 comments

Gradle 4.2.1

build.gradle.kts:

import org.jetbrains.kotlin.gradle.frontend.FrontendPlugin

buildscript {
    val kotlinVersion = "1.2-M2"

    repositories {
        jcenter()
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
        maven(url = "https://dl.bintray.com/kotlin/kotlin-dev")
    }
    dependencies {
        classpath(kotlin("gradle-plugin", kotlinVersion))
        classpath(kotlin("frontend-plugin", "latest.release"))
    }
}

apply {
    plugin("kotlin2js")
}
plugins.apply(FrontendPlugin::class.java)

repositories {
        jcenter()
        maven(url = "https://dl.bintray.com/kotlin/kotlin-dev")
}

val kotlinVersion = "1.2-M2"

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

BorzdeG avatar Oct 07 '17 03:10 BorzdeG

You can add the following to get it working

plugins {
    java
}

cy6erGn0m avatar Oct 18 '17 13:10 cy6erGn0m

@cy6erGn0m I expected that the plug-in itself will apply necessary plug-ins or will report that it lacks them. But not the message about the shortages of a configuration

BorzdeG avatar Oct 19 '17 09:10 BorzdeG

Unfortunately applying java plugin in frontend plugin is too late for kts build script. There is nothing can be done in frontend plugin to avoid this. Btw it is known issue and it is under discussion

cy6erGn0m avatar Oct 20 '17 10:10 cy6erGn0m

@cy6erGn0m this actually saved me, thank you.

What I do is:

  1. Create new kotlin + gradle kotlin dsl project in Idea 2017.3.1
  2. upgrade gradle-wrapper.properties: put gradle version 4.4-all there
  3. run ./gradlew wrapper (which gave me the error)

Your solution, with adding:

plugins {
    java
}

makes everything work again.

foxx1337 avatar Dec 16 '17 22:12 foxx1337

It is inappropriate to apply the java plugin to a project that isn't actually a java project.

The root problem causing this is that the kotlin-frontend plugin can't be applied via the Gradle plugins dsl, which provides the nice type-safe accessors.

See issue #143 for a description of why this is and how to fix it

sambsnyd avatar Mar 12 '19 00:03 sambsnyd