Skip to content

Commit

Permalink
use jdk17 for lint module
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartvick committed Mar 1, 2024
1 parent a1b6705 commit 7008140
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
29 changes: 23 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,24 @@ 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") {
lintJavaVersion
} else {
libJavaVersion
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
dokkaSourceSets.named("main") {
Expand All @@ -50,8 +67,8 @@ subprojects {
compileSdk = 34

compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
sourceCompatibility = libJavaVersion
targetCompatibility = libJavaVersion
}
}

Expand Down Expand Up @@ -89,13 +106,13 @@ subprojects {
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
sourceCompatibility = project.javaVersion().toString()
targetCompatibility = project.javaVersion().toString()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
jvmTarget = project.javaVersion().toString()
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions formula-lint/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask
import com.android.build.gradle.internal.lint.LintModelWriterTask
import com.fasterxml.jackson.module.kotlin.kotlinModule

plugins {
id("java-library")
Expand All @@ -22,3 +23,8 @@ dependencies {
testImplementation(libs.lint.tests)
testImplementation(libs.junit)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

0 comments on commit 7008140

Please sign in to comment.