未解决的参考:build.gradle.kts中的compileKotlin [英] Unresolved reference: compileKotlin in build.gradle.kts
本文介绍了未解决的参考:build.gradle.kts中的compileKotlin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Kotlin项目成功通过build.gradle构建:
Kotlin project success build by build.gradle:
compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
很好.
但是我需要更改为 build.gradle.kts :
plugins {
kotlin("jvm") version "1.2.10"
id("application")
}
group = "com.myproject"
version = "1.0-SNAPSHOT"
application {
mainClassName = "MainKt"
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
jcenter()
}
val kotlinVer = "1.2.10"
dependencies {
compile(kotlin(module = "stdlib-jre8", version = kotlinVer))
implementation("com.google.code.gson:gson:2.7")
implementation("com.squareup.okhttp3:logging-interceptor:3.8.0")
implementation("com.squareup.retrofit2:converter-gson:2.1.0")
implementation("com.squareup.retrofit2:retrofit:2.5.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
现在我得到了错误:
Line 32: compileKotlin {
^ Unresolved reference: compileKotlin
推荐答案
Kotlin Gradle DSL中存在一个导致此问题的问题.
There's an issue in the Kotlin Gradle DSL that causes this.
https://github.com/gradle/kotlin-dsl-samples/第/1368期
在解决该问题之前,您将需要使用以下变通方法.
You will need to use the following workaround until it gets resolved.
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
这篇关于未解决的参考:build.gradle.kts中的compileKotlin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文