Skip to content

Commit 47ad133

Browse files
committed
add stubs for firebase products not currently supported on jvm
1 parent 6f7804e commit 47ad133

File tree

8 files changed

+143
-14
lines changed

8 files changed

+143
-14
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<i>Development teams merge faster with GitLive</i><br/>
55
<br/>
66
<br/>
7-
The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the <a href="https://firebase.github.io/firebase-android-sdk/reference/kotlin/firebase-ktx/">Firebase Android SDK Kotlin Extensions</a> but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting <strong>iOS</strong>, <strong>Android</strong> or <strong>JS</strong>.
7+
The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the
8+
<a href="https://firebase.github.io/firebase-android-sdk/reference/kotlin/firebase-ktx/">Firebase Android SDK Kotlin Extensions</a>
9+
but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting
10+
<strong>iOS</strong>, <strong>Android</strong>, <strong>Desktop</strong> or <strong>Web</strong>, enabling the use of
11+
Firebase as a backend for<a href="https://www.jetbrains.com/lp/compose-multiplatform/">Compose Multiplatform</a>, for example.
812

913
## Available libraries
1014

@@ -202,6 +206,8 @@ In cases where it makes sense, such as Firebase Functions HTTPS Callable, operat
202206

203207
The Firebase Kotlin SDK provides a common API to access Firebase for projects targeting *iOS*, *Android* and *JS* meaning you can use Firebase directly in your common code. Under the hood, the SDK achieves this by binding to the respective official Firebase SDK for each supported platform.
204208

209+
It uses the <a href="https://github.com/GitLiveApp/firebase-java-sdk">Firebase Java SDK</a> to support the JVM target.
210+
205211
### Accessing the underlying Firebase SDK
206212

207213
In some cases you might want to access the underlying official Firebase SDK in platform specific code, for example when the common API is missing the functionality you need. For this purpose each class in the SDK has `android`, `ios` and `js` properties which holds the equivalent object of the underlying official Firebase SDK.

firebase-crashlytics/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
6-
import org.jetbrains.kotlin.konan.target.KonanTarget
7-
85
version = project.property("firebase-crashlytics.version") as String
96

107
plugins {
@@ -104,9 +101,9 @@ kotlin {
104101
}
105102
}
106103

107-
val jvmMain by getting {
108-
kotlin.srcDir("src/androidMain/kotlin")
109-
}
104+
// val jvmMain by getting {
105+
// kotlin.srcDir("src/androidMain/kotlin")
106+
// }
110107

111108
if (supportIosTarget) {
112109
val iosMain by getting
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package dev.gitlive.firebase.crashlytics
2+
3+
import dev.gitlive.firebase.Firebase
4+
import dev.gitlive.firebase.FirebaseApp
5+
import dev.gitlive.firebase.FirebaseException
6+
7+
/** Returns the [FirebaseCrashlytics] instance of the default [FirebaseApp]. */
8+
actual val Firebase.crashlytics: FirebaseCrashlytics
9+
get() = TODO("Not yet implemented")
10+
11+
/** Returns the [FirebaseCrashlytics] instance of a given [FirebaseApp]. */
12+
actual fun Firebase.crashlytics(app: FirebaseApp): FirebaseCrashlytics {
13+
TODO("Not yet implemented")
14+
}
15+
16+
actual class FirebaseCrashlytics {
17+
actual fun recordException(exception: Throwable) {
18+
}
19+
20+
actual fun log(message: String) {
21+
}
22+
23+
actual fun setUserId(userId: String) {
24+
}
25+
26+
actual fun setCustomKey(key: String, value: String) {
27+
}
28+
29+
actual fun setCustomKey(key: String, value: Boolean) {
30+
}
31+
32+
actual fun setCustomKey(key: String, value: Double) {
33+
}
34+
35+
actual fun setCustomKey(key: String, value: Float) {
36+
}
37+
38+
actual fun setCustomKey(key: String, value: Int) {
39+
}
40+
41+
actual fun setCustomKey(key: String, value: Long) {
42+
}
43+
44+
actual fun setCustomKeys(customKeys: Map<String, Any>) {
45+
}
46+
47+
actual fun setCrashlyticsCollectionEnabled(enabled: Boolean) {
48+
}
49+
50+
actual fun didCrashOnPreviousExecution(): Boolean {
51+
TODO("Not yet implemented")
52+
}
53+
54+
actual fun sendUnsentReports() {
55+
}
56+
57+
actual fun deleteUnsentReports() {
58+
}
59+
}
60+
61+
actual open class FirebaseCrashlyticsException : FirebaseException()

firebase-perf/build.gradle.kts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
6-
import org.jetbrains.kotlin.konan.target.KonanTarget
7-
85
version = project.property("firebase-perf.version") as String
96

107
plugins {
@@ -115,9 +112,9 @@ kotlin {
115112
}
116113
}
117114

118-
val jvmMain by getting {
119-
kotlin.srcDir("src/androidMain/kotlin")
120-
}
115+
// val jvmMain by getting {
116+
// kotlin.srcDir("src/androidMain/kotlin")
117+
// }
121118

122119
if (supportIosTarget) {
123120
val iosMain by getting
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package dev.gitlive.firebase.perf.metrics
2+
3+
actual class Trace {
4+
actual fun start() {
5+
}
6+
7+
actual fun stop() {
8+
}
9+
10+
actual fun getLongMetric(metricName: String): Long {
11+
TODO("Not yet implemented")
12+
}
13+
14+
actual fun incrementMetric(metricName: String, incrementBy: Long) {
15+
}
16+
17+
actual fun putMetric(metricName: String, value: Long) {
18+
}
19+
20+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dev.gitlive.firebase.perf
2+
3+
import dev.gitlive.firebase.Firebase
4+
import dev.gitlive.firebase.FirebaseApp
5+
import dev.gitlive.firebase.FirebaseException
6+
import dev.gitlive.firebase.perf.metrics.Trace
7+
8+
/** Returns the [FirebasePerformance] instance of the default [FirebaseApp]. */
9+
actual val Firebase.performance: FirebasePerformance
10+
get() = TODO("Not yet implemented")
11+
12+
/** Returns the [FirebasePerformance] instance of a given [FirebaseApp]. */
13+
actual fun Firebase.performance(app: FirebaseApp): FirebasePerformance {
14+
TODO("Not yet implemented")
15+
}
16+
17+
actual class FirebasePerformance {
18+
actual fun newTrace(traceName: String): Trace {
19+
TODO("Not yet implemented")
20+
}
21+
22+
actual fun isPerformanceCollectionEnabled(): Boolean {
23+
TODO("Not yet implemented")
24+
}
25+
26+
actual fun setPerformanceCollectionEnabled(enable: Boolean) {
27+
}
28+
29+
}
30+
31+
actual open class FirebasePerformanceException : FirebaseException()

settings.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ include(
55
"firebase-config",
66
"firebase-database",
77
"firebase-firestore",
8-
"firebase-functions"
8+
"firebase-functions",
9+
"firebase-installations",
10+
"firebase-perf",
11+
"firebase-crashlytics",
12+
"test-utils"
913
)
1014

test-utils/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ kotlin {
4040
publishAllLibraryVariants()
4141
}
4242

43+
jvm {
44+
val main by compilations.getting {
45+
kotlinOptions {
46+
jvmTarget = "17"
47+
}
48+
}
49+
val test by compilations.getting {
50+
kotlinOptions {
51+
jvmTarget = "17"
52+
}
53+
}
54+
}
55+
4356
val supportIosTarget = project.property("skipIosTarget") != "true"
4457

4558
if (supportIosTarget) {

0 commit comments

Comments
 (0)