如何在build.gradle.kts中设置compileJava'任务(11)和'compileKotlin'任务(1.8)jvm目标兼容性到相同的Java版本?
2022-08-31 19:57:40
Build.gradle.kts
buildscript {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath ("com.android.tools.build:gradle:7.0.2")
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30")
classpath("gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:${Versions.spotbugsGradlePluginVersion}")
classpath("se.bjurr.violations:violations-gradle-plugin:${Versions.violationsVersion}")
}
}
//android {
// compileOptions {
// sourceCompatibility = JavaVersion.VERSION_11
// targetCompatibility = JavaVersion.VERSION_11
// }
//
// kotlinOptions {
// jvmTarget = JavaVersion.VERSION_11.toString()
// }
//}
plugins {
`maven-publish`
`java-gradle-plugin`
`kotlin-dsl`
id ("io.gitlab.arturbosch.detekt") version ("1.18.1")
}
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
compileOnly(gradleApi())
testImplementation(gradleTestKit())
testImplementation("junit:junit:${Versions.jUnitVersion}")
}
val generatedSources = tasks.register<GenerateVersionsFileTask>("generateSources")
错误:'compileJava'任务(当前目标是11)和'compileKotlin'任务(当前目标是1.8)jvm目标兼容性应设置为相同的Java版本。
当我取消注释安卓{}错误:脚本编译错误:
Line 15: android {
^ Unresolved reference: android
感谢您:)的时间和精力吉滕德拉