Skip to content

Commit 1ea71d3

Browse files
committed
use jdk17 for lint module
1 parent a1b6705 commit 1ea71d3

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Diff for: build.gradle.kts

+24-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,25 @@ allprojects {
3434
}
3535

3636
subprojects {
37-
val javaVersion = JavaVersion.VERSION_18
37+
38+
val libJavaVersion = JavaVersion.VERSION_18
39+
val lintJavaVersion = JavaVersion.VERSION_17
40+
41+
/**
42+
* We explicitly target JDK 17 for the lint module in order to be compatible with current Android Studio JRE version (JBR17),
43+
* as lint checks compiled with JDK 18 are failing to be run by the code inspector.
44+
*
45+
* We should be able to update back to JDK 18 once AS ships with JBR21 (likely IDEA 2024.1):
46+
* https://github.com/JetBrains/JetBrainsRuntime?tab=readme-ov-file#releases-based-on-jdk-21
47+
*/
48+
fun Project.javaVersion(): JavaVersion {
49+
return if (name == "formula-lint") {
50+
logger.lifecycle("")
51+
lintJavaVersion
52+
} else {
53+
libJavaVersion
54+
}
55+
}
3856

3957
tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
4058
dokkaSourceSets.named("main") {
@@ -50,8 +68,8 @@ subprojects {
5068
compileSdk = 34
5169

5270
compileOptions {
53-
sourceCompatibility = javaVersion
54-
targetCompatibility = javaVersion
71+
sourceCompatibility = libJavaVersion
72+
targetCompatibility = libJavaVersion
5573
}
5674
}
5775

@@ -89,13 +107,13 @@ subprojects {
89107
}
90108

91109
tasks.withType<JavaCompile>().configureEach {
92-
sourceCompatibility = javaVersion.toString()
93-
targetCompatibility = javaVersion.toString()
110+
sourceCompatibility = project.javaVersion().toString()
111+
targetCompatibility = project.javaVersion().toString()
94112
}
95113

96114
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
97115
kotlinOptions {
98-
jvmTarget = javaVersion.toString()
116+
jvmTarget = project.javaVersion().toString()
99117
}
100118
}
101119
}

0 commit comments

Comments
 (0)