From 54b04e1bd3093bd18df33cdffc5830fdb420dbd9 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 9 Dec 2025 12:33:52 +0100 Subject: [PATCH] Upgrades dependencies for FB 34 --- build.gradle.kts | 18 +++-------- gradle.properties | 2 +- gradle/libs.versions.toml | 31 ++++++++++--------- .../com/google/firebase/auth/FirebaseAuth.kt | 25 ++++++++------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8466b03..15ff468 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.util.Locale buildscript { @@ -20,7 +21,7 @@ plugins { alias(libs.plugins.publish) alias(libs.plugins.kotlin.jvm) alias(libs.plugins.kotlinx.serialization) - alias(libs.plugins.jlleitschuh.ktlint) + alias(libs.plugins.kotlinter) alias(libs.plugins.ben.manes.versions) } @@ -57,14 +58,10 @@ val extractClasses by tasks.registering(Copy::class) { tasks { compileKotlin { dependsOn(extractClasses) - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - } + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } compileTestKotlin { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() - } + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } withType().configureEach { onlyIf { !project.gradle.startParameter.taskNames.any { "MavenLocal" in it } } @@ -147,8 +144,7 @@ dependencies { aar(libs.google.firebase.installations) aar(libs.google.firebase.storage) // extracted aar dependencies - // exclude lifecycle libs due to https://github.com/GitLiveApp/firebase-java-sdk/pull/15 - remove the exclude once the dependencies in the aars are updated to the required version - api(fileTree(mapOf("dir" to "build/jar", "include" to listOf("*.jar"), "exclude" to listOf("lifecycle-*")))) + api(fileTree(mapOf("dir" to "build/jar", "include" to listOf("*.jar")))) // polyfill dependencies implementation(libs.kotlinx.coroutines.core) implementation(libs.kotlinx.serialization.core) @@ -173,10 +169,6 @@ tasks.named("publish").configure { dependsOn(cleanLibs) } -ktlint { - version.set(libs.versions.ktlint.get()) -} - tasks.withType { fun isNonStable(version: String): Boolean { diff --git a/gradle.properties b/gradle.properties index 240ac2f..be60622 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.6.3 +version=0.6.4 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index be3c5f4..bda791a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,17 +1,20 @@ [versions] -androidx-lifecycle = "2.10.0-alpha01" +androidx-lifecycle = "2.10.0" +androidx-collection = "1.5.0" +okhttp="5.3.2" +sqlite="3.51.1.0" +robolectric="16-robolectric-13921718" ben-manes-versions = "0.51.0" -google-firebase-bom = "32.7.0" -io-grpc = "1.68.0" -jlleitschuh-ktlint = "12.1.1" -kotlin = "2.0.20" -kotlinx-coroutines = "1.9.0" -kotlinx-serialization = "1.7.2" -ktlint = "0.47.1" -publish = "0.34.0" +google-firebase-bom = "34.6.0" +io-grpc = "1.77.0" +kotlinter = "5.3.0" +kotlin = "2.2.21" +kotlinx-coroutines = "1.10.2" +kotlinx-serialization = "1.9.0" +publish = "0.35.0" [libraries] -androidx-collection = { module = "androidx.collection:collection", version = "1.4.3" } +androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" } androidx-lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "androidx-lifecycle" } androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle" } google-firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "google-firebase-bom" } @@ -32,13 +35,13 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines- kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } -okhttp = { module = "com.squareup.okhttp3:okhttp", version = "3.12.13" } -robolectric-android-all = { module = "org.robolectric:android-all", version = "14-robolectric-10818077" } -xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version = "3.46.1.0" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } +robolectric-android-all = { module = "org.robolectric:android-all", version.ref = "robolectric" } +xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite" } [plugins] ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "ben-manes-versions" } -jlleitschuh-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "jlleitschuh-ktlint" } +kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/src/main/java/com/google/firebase/auth/FirebaseAuth.kt b/src/main/java/com/google/firebase/auth/FirebaseAuth.kt index 15312ba..8c72af0 100644 --- a/src/main/java/com/google/firebase/auth/FirebaseAuth.kt +++ b/src/main/java/com/google/firebase/auth/FirebaseAuth.kt @@ -34,6 +34,7 @@ import kotlinx.serialization.json.longOrNull import okhttp3.Call import okhttp3.Callback import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody @@ -237,7 +238,7 @@ data class FirebaseUserImpl internal constructor( class FirebaseAuth constructor( val app: FirebaseApp ) : InternalAuthProvider { - internal val json = MediaType.parse("application/json; charset=utf-8") + internal val json = "application/json; charset=utf-8".toMediaTypeOrNull() internal val client: OkHttpClient = OkHttpClient .Builder() @@ -276,7 +277,7 @@ class FirebaseAuth constructor( createAuthInvalidUserException("accounts", request, response) ) } else { - if (response.body()?.use { it.string() }?.also { responseBody -> + if (response.body.use { it.string() }?.also { responseBody -> user = setResult(responseBody) source.setResult(AuthResult { user }) } == null @@ -411,7 +412,7 @@ class FirebaseAuth constructor( val newBody = jsonParser .parseToJsonElement( - response.body()?.use { it.string() } ?: "" + response.body?.use { it.string() } ?: "" ).jsonObject user = user?.copy( @@ -486,7 +487,7 @@ class FirebaseAuth constructor( request: Request, response: Response ): FirebaseAuthInvalidUserException { - val body = response.body()!!.use { it.string() } + val body = response.body.use { it.string() } val jsonObject = jsonParser.parseToJsonElement(body).jsonObject return FirebaseAuthInvalidUserException( @@ -497,20 +498,20 @@ class FirebaseAuth constructor( ?.contentOrNull ?: "UNKNOWN_ERROR", "$action API returned an error, " + - "with url [${request.method()}] ${request.url()} ${request.body()} -- " + - "response [${response.code()}] ${response.message()} $body" + "with url [${request.method}] ${request.url} ${request.body} -- " + + "response [${response.code}] ${response.message} $body" ) } fun signOut() { // cancel token refresher client - .dispatcher() + .dispatcher .queuedCalls() .find { it.request().tag() == REFRESH_TOKEN_TAG } ?.cancel() ?: { client - .dispatcher() + .dispatcher .runningCalls() .find { it.request().tag() == REFRESH_TOKEN_TAG } ?.cancel() @@ -579,9 +580,9 @@ class FirebaseAuth constructor( call: Call, response: Response ) { - val responseBody = response.body()?.use { it.string() } + val responseBody = response.body.use { it.string() } - if (!response.isSuccessful || responseBody == null) { + if (!response.isSuccessful) { signOutAndThrowInvalidUserException(responseBody.orEmpty(), "token API returned an error: $body") } else { jsonParser.parseToJsonElement(responseBody).jsonObject.apply { @@ -659,7 +660,7 @@ class FirebaseAuth constructor( val newBody = jsonParser .parseToJsonElement( - response.body()?.use { it.string() } ?: "" + response.body.use { it.string() } ).jsonObject user?.let { prev -> @@ -734,7 +735,7 @@ class FirebaseAuth constructor( val newBody = jsonParser .parseToJsonElement( - response.body()?.use { it.string() } ?: "" + response.body.use { it.string() } ).jsonObject user?.let { prev ->