From 8d2c7df1ddfec41b801ae6e3ff2301b3f8dacd2c Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Sun, 24 Sep 2023 11:32:28 +0200 Subject: [PATCH] chore(*): workaround to set kapt jvm target version 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 --- build.gradle | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2f2fa9f8..47055d37 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + buildscript { ext { versionCode = 001_006_000 @@ -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 }