gpt4 book ai didi

gradle - 未解析的引用 : compileKotlin in build. gradle.kts

转载 作者:行者123 更新时间:2023-12-04 18:18:52 30 4
gpt4 key购买 nike

通过 build.gradle 构建 Kotlin 项目成功:

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 中存在导致此问题的问题。
https://github.com/gradle/kotlin-dsl-samples/issues/1368
您将需要使用以下解决方法,直到问题得到解决。

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}

关于gradle - 未解析的引用 : compileKotlin in build. gradle.kts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55456176/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com