Skip to content

Commit

Permalink
chore(*): workaround to set kapt jvm target version
Browse files Browse the repository at this point in the history
The purpose is to fix error:
```
> 'compileJava' task (current target is 18) and 'kaptGenerateStubsKotlin' 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
 ```
 See https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version#focus=Comments-27-6805028.0-0
  • Loading branch information
ThibaultBee committed Sep 24, 2023
1 parent 6309f40 commit 8d2c7df
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
ext {
versionCode = 001_006_000
Expand Down Expand Up @@ -26,6 +28,20 @@ allprojects {
}
}

task clean(type: Delete) {
subprojects {
afterEvaluate{
tasks.withType(KotlinCompile).tap {
configureEach {
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) {
kotlinOptions.jvmTarget = android.compileOptions.sourceCompatibility
} else {
kotlinOptions.jvmTarget = sourceCompatibility
}
}
}
}
}

tasks.register('clean', Delete) {
delete rootProject.buildDir
}

0 comments on commit 8d2c7df

Please sign in to comment.