@@ -34,7 +34,25 @@ allprojects {
34
34
}
35
35
36
36
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
+ }
38
56
39
57
tasks.withType< org.jetbrains.dokka.gradle.DokkaTaskPartial > ().configureEach {
40
58
dokkaSourceSets.named(" main" ) {
@@ -50,8 +68,8 @@ subprojects {
50
68
compileSdk = 34
51
69
52
70
compileOptions {
53
- sourceCompatibility = javaVersion
54
- targetCompatibility = javaVersion
71
+ sourceCompatibility = libJavaVersion
72
+ targetCompatibility = libJavaVersion
55
73
}
56
74
}
57
75
@@ -89,13 +107,13 @@ subprojects {
89
107
}
90
108
91
109
tasks.withType<JavaCompile >().configureEach {
92
- sourceCompatibility = javaVersion.toString()
93
- targetCompatibility = javaVersion.toString()
110
+ sourceCompatibility = project. javaVersion() .toString()
111
+ targetCompatibility = project. javaVersion() .toString()
94
112
}
95
113
96
114
tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > ().configureEach {
97
115
kotlinOptions {
98
- jvmTarget = javaVersion.toString()
116
+ jvmTarget = project. javaVersion() .toString()
99
117
}
100
118
}
101
119
}
0 commit comments