Intellij拒绝将Kotlin目标jvm设置为1.8? [英] Intellij refuses to set the Kotlin target jvm to 1.8?
本文介绍了Intellij拒绝将Kotlin目标jvm设置为1.8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ParallelStreams.kts:41:15: error: calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
IntStream.range(0,10).parallel().forEach{a ->
^
好吧...我不是要为1.6编译.
Ok ... I'm not trying to compile for 1.6.
File > Project Structure > Project
具有项目sdk 1.8
和语言级别8
.
File > Project Structure > Project
has project sdk 1.8
and language level 8
.
File > Project Structure > Modules > Kotlin
具有目标平台:JVM 1.8
.
File > Project Structure > Facets > Kotlin
具有目标平台:JVM 1.8
.
File > Settings > Compiler > Kotlin Compiler
具有目标jvm版本1.8
.
File > Settings > Compiler > Kotlin Compiler
has target jvm version 1.8
.
我的gradle构建文件...
My gradle build file ...
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
group 'foo'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.3.0"
//networking
implementation 'com.mashape.unirest:unirest-java:1.4.9'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
我没有地方去检查1.8
.
是的,我 已经 尝试使缓存无效并重新启动Intellij.它无能解决此问题.
And yes, I have tried invalidating the cache and restarting Intellij. It does nothing to resolve this issue.
推荐答案
使用.kts
只需使用此:
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
// I am using latest dsl and gradle
val kotlinVersion = "1.3.30"
val gradleVersion = "5.4+"
这篇关于Intellij拒绝将Kotlin目标jvm设置为1.8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文