@@ -34,7 +34,24 @@ allprojects {
3434}
3535
3636subprojects {
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+ lintJavaVersion
51+ } else {
52+ libJavaVersion
53+ }
54+ }
3855
3956 tasks.withType< org.jetbrains.dokka.gradle.DokkaTaskPartial > ().configureEach {
4057 dokkaSourceSets.named(" main" ) {
@@ -50,8 +67,8 @@ subprojects {
5067 compileSdk = 34
5168
5269 compileOptions {
53- sourceCompatibility = javaVersion
54- targetCompatibility = javaVersion
70+ sourceCompatibility = libJavaVersion
71+ targetCompatibility = libJavaVersion
5572 }
5673 }
5774
@@ -89,13 +106,13 @@ subprojects {
89106 }
90107
91108 tasks.withType<JavaCompile >().configureEach {
92- sourceCompatibility = javaVersion.toString()
93- targetCompatibility = javaVersion.toString()
109+ sourceCompatibility = project. javaVersion() .toString()
110+ targetCompatibility = project. javaVersion() .toString()
94111 }
95112
96113 tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > ().configureEach {
97114 kotlinOptions {
98- jvmTarget = javaVersion.toString()
115+ jvmTarget = project. javaVersion() .toString()
99116 }
100117 }
101118}
0 commit comments