Skip to content

Commit

Permalink
Allow building with Java 20 and later versions
Browse files Browse the repository at this point in the history
Update the KotlinCompile args to add `-Xjdk-release=1.8` which is the
equivalent of the `--release 8` argument when compiling Java code. This
will ensure that we only use APIs which are in Java 1.8 and not added in
later versions. This fixes compiler warnings around use of
`new URL(String)` which is deprecated starting in Java 20.
  • Loading branch information
pkwarren committed Nov 8, 2023
1 parent 37fb4f9 commit 2f29dfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ subprojects {
jvmTarget = "1.8"
languageVersion = "1.6"
apiVersion = "1.6"
if (JavaVersion.current().isJava9Compatible && project.name != "android") {
freeCompilerArgs += "-Xjdk-release=1.8"
}
}
}
tasks.withType<JavaCompile> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spotless = "6.22.0"
android = { module = "com.google.android:android", version.ref = "android" }
android-material = { module = "com.google.android.material:material", version = "1.10.0" }
android-multidex = { module = "com.android.support:multidex", version = "1.0.3" }
android-plugin = { module = "com.android.tools.build:gradle", version = "8.1.2" }
android-plugin = { module = "com.android.tools.build:gradle", version = "8.1.3" }
androidx-annotations = { module = "androidx.annotation:annotation", version = "1.7.0" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" }
androidx-compose = { module = "androidx.activity:activity-compose", version = "1.8.0" }
Expand Down

0 comments on commit 2f29dfd

Please sign in to comment.