简书链接:kaptGenerateStubsReleaseKotlintaskcurrenttargetis17jvmtarget
文章字数:191,阅读全文大约需要1分钟
发现代码中没有17

1
2
3
4
5
6
7
8
9
compileOptions {
sourceCompatibility(JavaVersion.VERSION_11)
targetCompatibility(JavaVersion.VERSION_11)
}

kotlinOptions {
jvmTarget = "11"
}

image.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':base_extend:kaptGenerateStubsReleaseKotlin'.
> 'compileReleaseJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsReleaseKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':base:kaptGenerateStubsReleaseKotlin'.
> 'compileReleaseJavaWithJavac' task (current target is 11) and 'kaptGenerateStubsReleaseKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain


* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================
1
2
3
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs).configureEach{
kotlinOptions{jvmTarget = "1.8"}
}

image.png

1
2
3
4
5
6

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}

全局

image.png

1
2
3
4
5
6
7
allprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
}

https://kotlinlang.org/docs/gradle-configure-project.html?utm_campaign=gradle-jvm-toolchain&utm_medium=kgp&utm_source=warnings#other-details
https://www.null123.com/question/detail-2720063.html
https://www.saoniuhuo.com/question/detail-2492575.html