kotlin-frontend-plugin
kotlin-frontend-plugin copied to clipboard
build.gradle.kts: Unresolved reference: compile
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))
}
You can add the following to get it working
plugins {
java
}
@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
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 this actually saved me, thank you.
What I do is:
- Create new kotlin + gradle kotlin dsl project in Idea 2017.3.1
- upgrade
gradle-wrapper.properties
: put gradle version 4.4-all there - run
./gradlew wrapper
(which gave me the error)
Your solution, with adding:
plugins {
java
}
makes everything work again.
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