From ccfec12e43a3b59503ffeea140547518545ab073 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:41:42 +0000 Subject: [PATCH 1/4] Bump org.jetbrains.kotlinx:kotlinx-serialization-core Bumps [org.jetbrains.kotlinx:kotlinx-serialization-core](https://github.com/Kotlin/kotlinx.serialization) from 1.7.1 to 1.7.2. - [Release notes](https://github.com/Kotlin/kotlinx.serialization/releases) - [Changelog](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md) - [Commits](https://github.com/Kotlin/kotlinx.serialization/compare/v1.7.1...v1.7.2) --- updated-dependencies: - dependency-name: org.jetbrains.kotlinx:kotlinx-serialization-core dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 712b20d3a..36bcf1e6e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ gson = "2.11.0" junit = "4.13.2" kotlin = "2.0.20" kotlinx-coroutines = "1.9.0-RC.2" -kotlinx-serialization = "1.7.1" +kotlinx-serialization = "1.7.2" kotlinx-binarycompatibilityvalidator = "0.16.3" kotlinx-datetime = "0.6.1" kotlinter = "4.4.1" From 7af92d46fca228ab684abb062222a7018325b23f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 01:41:58 +0000 Subject: [PATCH 2/4] Bump agp from 8.5.2 to 8.6.0 Bumps `agp` from 8.5.2 to 8.6.0. Updates `com.android.tools.build:gradle` from 8.5.2 to 8.6.0 Updates `com.android.application` from 8.5.2 to 8.6.0 --- updated-dependencies: - dependency-name: com.android.tools.build:gradle dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: com.android.application dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 712b20d3a..fd87da287 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.5.2" +agp = "8.6.0" androidx-test-core = "1.6.1" androidx-test-junit = "1.2.1" androidx-test-runner = "1.6.2" From 5535b9fe5d5572ad8eccb8e0e4b29002f264a371 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 3 Sep 2024 10:40:04 +0200 Subject: [PATCH 3/4] Disable Desugaring for the library itself --- README.md | 6 +++++- firebase-common-internal/package.json | 4 ++-- firebase-config/build.gradle.kts | 5 ----- gradle/libs.versions.toml | 2 -- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2656b6ef0..eec45beb0 100644 --- a/README.md +++ b/README.md @@ -269,9 +269,13 @@ These properties are only accessible from the equivalent target's source set. Fo .build() ``` +### Running on Android + +On android, some modules (`config`) require you to enable [Core library desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) if you have a *minSDK lower than API 26*. + ### Running on iOS -On iOS the official [Firebase iOS SDK](https://github.com/firebase/firebase-ios-sdk) in not linked as a transtive dependency. Therefore, any project using this SDK needs to link the actual Firestore SDK as well. This can be done through your preferred installation method (Cocoapods/SPM). +On iOS the official [Firebase iOS SDK](https://github.com/firebase/firebase-ios-sdk) in not linked as a transitive dependency. Therefore, any project using this SDK needs to link the actual Firestore SDK as well. This can be done through your preferred installation method (Cocoapods/SPM). Similarly, tests require linking as well. Make sure to add the required frameworks to the search path of your test targets. This can be done by specifying a `cocoapods` block in your `build.gradle`: ```kotlin diff --git a/firebase-common-internal/package.json b/firebase-common-internal/package.json index c1a555b9e..9548da6c3 100644 --- a/firebase-common-internal/package.json +++ b/firebase-common-internal/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common-internal", - "version": "2.0.0", + "version": "2.1.0", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common-internal.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-multiplatform-sdk", "dependencies": { - "@gitlive/firebase-common": "2.0.0", + "@gitlive/firebase-common": "2.1.0", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4", diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index a28086463..f942264e4 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -29,7 +29,6 @@ android { } compileOptions { - isCoreLibraryDesugaringEnabled = true sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } @@ -45,10 +44,6 @@ android { } } -dependencies { - coreLibraryDesugaring(libs.android.desugarjdk) -} - val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7ea0120e9..dc853f7e0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -20,7 +20,6 @@ firebase-cocoapods = "11.1.0" ios-deploymentTarget = "13.0" test-logger-plugin = "4.0.0" dokka = "1.9.20" -desugar-libs = "2.1.1" [libraries] android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } @@ -50,7 +49,6 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines- kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" } -android-desugarjdk = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar-libs" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } From 4176fe6d63736b01adcac926910f5890b8f517c3 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Fri, 13 Sep 2024 13:23:03 +0200 Subject: [PATCH 4/4] Make builders abstract to allow for testing --- .../api/android/firebase-firestore.api | 11 +++++----- .../api/jvm/firebase-firestore.api | 11 +++++----- .../firebase/firestore/FieldValueBuilder.kt | 7 ++----- .../firestore/FieldsAndValuesBuilder.kt | 12 +++-------- .../gitlive/firebase/firestore/firestore.kt | 14 ++++++------- .../firestore/internal/FieldValueBuilder.kt | 15 +++++++++++++ .../internal/FieldsAndValuesBuilder.kt | 21 +++++++++++++++++++ 7 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt create mode 100644 firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt diff --git a/firebase-firestore/api/android/firebase-firestore.api b/firebase-firestore/api/android/firebase-firestore.api index 9cf847e6b..21a2909de 100644 --- a/firebase-firestore/api/android/firebase-firestore.api +++ b/firebase-firestore/api/android/firebase-firestore.api @@ -160,8 +160,8 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class dev/gitlive/firebase/firestore/FieldValueBuilder { - public final fun addEncoded (Ljava/lang/Object;)V +public abstract class dev/gitlive/firebase/firestore/FieldValueBuilder { + public abstract fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V @@ -176,13 +176,14 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { +public abstract class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { + public fun ()V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V - public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V + public abstract fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public abstract fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V } public abstract class dev/gitlive/firebase/firestore/Filter { diff --git a/firebase-firestore/api/jvm/firebase-firestore.api b/firebase-firestore/api/jvm/firebase-firestore.api index 6b5abda69..5c628e0aa 100644 --- a/firebase-firestore/api/jvm/firebase-firestore.api +++ b/firebase-firestore/api/jvm/firebase-firestore.api @@ -160,8 +160,8 @@ public final class dev/gitlive/firebase/firestore/FieldValue$Companion { public final fun serializer ()Lkotlinx/serialization/KSerializer; } -public final class dev/gitlive/firebase/firestore/FieldValueBuilder { - public final fun addEncoded (Ljava/lang/Object;)V +public abstract class dev/gitlive/firebase/firestore/FieldValueBuilder { + public abstract fun addEncoded (Ljava/lang/Object;)V public final fun addWithStrategy (Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V @@ -176,13 +176,14 @@ public final class dev/gitlive/firebase/firestore/FieldValueSerializer : kotlinx public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V } -public final class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { +public abstract class dev/gitlive/firebase/firestore/FieldsAndValuesBuilder { + public fun ()V public final fun getBuildSettings ()Lkotlin/jvm/functions/Function1; public final fun setBuildSettings (Lkotlin/jvm/functions/Function1;)V public final fun to (Ldev/gitlive/firebase/firestore/FieldPath;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V public final fun to (Ljava/lang/String;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V - public final fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V - public final fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V + public abstract fun toEncoded (Ldev/gitlive/firebase/firestore/FieldPath;Ljava/lang/Object;)V + public abstract fun toEncoded (Ljava/lang/String;Ljava/lang/Object;)V } public abstract class dev/gitlive/firebase/firestore/Filter { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt index 53d5a0d13..626ab89f2 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldValueBuilder.kt @@ -3,9 +3,8 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.EncodeSettings import kotlinx.serialization.SerializationStrategy -public class FieldValueBuilder internal constructor() { +public abstract class FieldValueBuilder internal constructor() { - internal val fieldValues: MutableList = mutableListOf() public var buildSettings: EncodeSettings.Builder.() -> Unit = { encodeDefaults = true } @@ -19,7 +18,5 @@ public class FieldValueBuilder internal constructor() { } @PublishedApi - internal fun addEncoded(encodedValue: Any) { - fieldValues += encodedValue - } + internal abstract fun addEncoded(encodedValue: Any) } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt index aba64b228..b3886f4f8 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/FieldsAndValuesBuilder.kt @@ -1,12 +1,10 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.EncodeSettings -import dev.gitlive.firebase.firestore.internal.FieldAndValue import kotlinx.serialization.SerializationStrategy -public class FieldsAndValuesBuilder internal constructor() { +public abstract class FieldsAndValuesBuilder { - internal val fieldAndValues: MutableList = mutableListOf() public var buildSettings: EncodeSettings.Builder.() -> Unit = { encodeDefaults = true } @@ -28,12 +26,8 @@ public class FieldsAndValuesBuilder internal constructor() { } @PublishedApi - internal fun String.toEncoded(encodedValue: Any?) { - fieldAndValues += FieldAndValue.WithStringField(this, encodedValue) - } + internal abstract fun String.toEncoded(encodedValue: Any?) @PublishedApi - internal fun FieldPath.toEncoded(encodedValue: Any?) { - fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue) - } + internal abstract fun FieldPath.toEncoded(encodedValue: Any?) } diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index c87f4194c..2a5f9ad73 100644 --- a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -224,7 +224,7 @@ public data class Transaction internal constructor(internal val nativeWrapper: N public fun update( documentRef: DocumentReference, fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, - ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)) + ): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues)) @PublishedApi internal fun updateEncoded(documentRef: DocumentReference, encodedData: EncodedObject): Transaction = Transaction(nativeWrapper.updateEncoded(documentRef, encodedData)) @@ -263,7 +263,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun startAfter(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAfter(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun startAt(document: DocumentSnapshot): Query = Query(nativeQuery.startAt(document.native)) public fun startAt(vararg fieldValues: Any?): Query = startAt({}, *fieldValues) @@ -275,7 +275,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun startAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.startAt(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun endBefore(document: DocumentSnapshot): Query = Query(nativeQuery.endBefore(document.native)) public fun endBefore(vararg fieldValues: Any?): Query = endBefore({}, *fieldValues) @@ -287,7 +287,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun endBefore(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endBefore(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) public fun endAt(document: DocumentSnapshot): Query = Query(nativeQuery.endAt(document.native)) public fun endAt(vararg fieldValues: Any?): Query = endAt({}, *fieldValues) @@ -299,7 +299,7 @@ public open class Query internal constructor(internal val nativeQuery: NativeQue } } - public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) + public fun endAt(builder: FieldValueBuilder.() -> Unit): Query = Query(nativeQuery.endAt(*dev.gitlive.firebase.firestore.internal.FieldValueBuilder().apply(builder).fieldValues.toTypedArray())) } @Deprecated("Deprecated in favor of using a [FilterBuilder]", replaceWith = ReplaceWith("where { field equalTo equalTo }", "dev.gitlive.firebase.firestore")) @@ -461,7 +461,7 @@ public data class WriteBatch internal constructor(internal val nativeWrapper: Na ): WriteBatch = WriteBatch( nativeWrapper.updateEncoded( documentRef, - FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues, + dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldAndValuesBuilder).fieldAndValues, ), ) @@ -633,7 +633,7 @@ public data class DocumentReference internal constructor(internal val native: Na public suspend fun update( fieldsAndValuesBuilder: FieldsAndValuesBuilder.() -> Unit, ) { - native.updateEncoded(FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues) + native.updateEncoded(dev.gitlive.firebase.firestore.internal.FieldsAndValuesBuilder().apply(fieldsAndValuesBuilder).fieldAndValues) } public suspend fun delete() { diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt new file mode 100644 index 000000000..16121a389 --- /dev/null +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldValueBuilder.kt @@ -0,0 +1,15 @@ +package dev.gitlive.firebase.firestore.internal + +import kotlin.experimental.ExperimentalObjCName +import kotlin.native.ObjCName + +@OptIn(ExperimentalObjCName::class) +@ObjCName("FieldValueBuilderImpl") +internal class FieldValueBuilder : dev.gitlive.firebase.firestore.FieldValueBuilder() { + + internal val fieldValues: MutableList = mutableListOf() + + override fun addEncoded(encodedValue: Any) { + fieldValues += encodedValue + } +} diff --git a/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt new file mode 100644 index 000000000..08307d13f --- /dev/null +++ b/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/internal/FieldsAndValuesBuilder.kt @@ -0,0 +1,21 @@ +package dev.gitlive.firebase.firestore.internal + +import dev.gitlive.firebase.firestore.FieldPath +import dev.gitlive.firebase.firestore.FieldsAndValuesBuilder +import kotlin.experimental.ExperimentalObjCName +import kotlin.native.ObjCName + +@OptIn(ExperimentalObjCName::class) +@ObjCName("FieldsAndValuesBuilderImpl") +internal class FieldsAndValuesBuilder : FieldsAndValuesBuilder() { + + internal val fieldAndValues: MutableList = mutableListOf() + + override fun String.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithStringField(this, encodedValue) + } + + override fun FieldPath.toEncoded(encodedValue: Any?) { + fieldAndValues += FieldAndValue.WithFieldPath(this, encodedValue) + } +}