From 1ea71d30d7a04af9a4a7f5e8c9405accc9f98caf Mon Sep 17 00:00:00 2001 From: Mathieu Hartvick Date: Fri, 1 Mar 2024 13:22:32 -0500 Subject: [PATCH] use jdk17 for lint module --- build.gradle.kts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 47a5f50a..f0e2ab60 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,25 @@ allprojects { } subprojects { - val javaVersion = JavaVersion.VERSION_18 + + val libJavaVersion = JavaVersion.VERSION_18 + val lintJavaVersion = JavaVersion.VERSION_17 + + /** + * We explicitly target JDK 17 for the lint module in order to be compatible with current Android Studio JRE version (JBR17), + * as lint checks compiled with JDK 18 are failing to be run by the code inspector. + * + * We should be able to update back to JDK 18 once AS ships with JBR21 (likely IDEA 2024.1): + * https://github.com/JetBrains/JetBrainsRuntime?tab=readme-ov-file#releases-based-on-jdk-21 + */ + fun Project.javaVersion(): JavaVersion { + return if (name == "formula-lint") { + logger.lifecycle("") + lintJavaVersion + } else { + libJavaVersion + } + } tasks.withType().configureEach { dokkaSourceSets.named("main") { @@ -50,8 +68,8 @@ subprojects { compileSdk = 34 compileOptions { - sourceCompatibility = javaVersion - targetCompatibility = javaVersion + sourceCompatibility = libJavaVersion + targetCompatibility = libJavaVersion } } @@ -89,13 +107,13 @@ subprojects { } tasks.withType().configureEach { - sourceCompatibility = javaVersion.toString() - targetCompatibility = javaVersion.toString() + sourceCompatibility = project.javaVersion().toString() + targetCompatibility = project.javaVersion().toString() } tasks.withType().configureEach { kotlinOptions { - jvmTarget = javaVersion.toString() + jvmTarget = project.javaVersion().toString() } } }