Skip to content

Commit 7008140

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

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

build.gradle.kts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,24 @@ 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+
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
}

formula-lint/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask
22
import com.android.build.gradle.internal.lint.LintModelWriterTask
3+
import com.fasterxml.jackson.module.kotlin.kotlinModule
34

45
plugins {
56
id("java-library")
@@ -22,3 +23,8 @@ dependencies {
2223
testImplementation(libs.lint.tests)
2324
testImplementation(libs.junit)
2425
}
26+
27+
java {
28+
sourceCompatibility = JavaVersion.VERSION_17
29+
targetCompatibility = JavaVersion.VERSION_17
30+
}

0 commit comments

Comments
 (0)