Skip to content

Commit 515a858

Browse files
authored
Merge pull request #4 from TeamHubApp/upgrade-to-kotlin-1-3-7-0
upgrade kotlin
2 parents 2efab25 + bea8868 commit 515a858

File tree

34 files changed

+331
-298
lines changed

34 files changed

+331
-298
lines changed

build.gradle.kts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
kotlin("multiplatform") version "1.3.61" apply false
2+
kotlin("multiplatform") version "1.3.70" apply false
33
}
44

55
buildscript {
@@ -37,17 +37,17 @@ subprojects {
3737
afterEvaluate {
3838
dependencies {
3939
"commonMainImplementation"(kotlin("stdlib-common"))
40-
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.3")
40+
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.4")
4141
"jsMainImplementation"(kotlin("stdlib-js"))
42-
"jsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.3")
43-
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
44-
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.3")
42+
"jsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.4")
43+
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4")
44+
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.4")
4545
"jvmMainImplementation"(kotlin("stdlib-jdk8"))
46-
"jvmMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
47-
"jvmMainApi"("app.teamhub:firebase-java:0.3.0")
48-
"jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.3")
49-
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.3")
50-
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.3")
46+
"jvmMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4")
47+
"jvmMainApi"("app.teamhub:firebase-java:0.3.1")
48+
"jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.4")
49+
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.4")
50+
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.4")
5151
}
5252
}
5353
}

firebase-app/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
google()
1212
}
1313

14-
version = "0.1.0-dev"
14+
version = "0.1.0-beta"
1515

1616
android {
1717
compileSdkVersion(property("targetSdkVersion") as Int)
@@ -104,8 +104,8 @@ tasks {
104104
into.createNewFile()
105105
into.writeText(from.readText()
106106
.replace("require('firebase-", "require('@teamhubapp/firebase-")
107-
.replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@cachet/kotlinx-serialization-runtime')")
108-
)
107+
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@teamhub/kotlinx-serialization-runtime')")
108+
)
109109
}
110110
}
111111

firebase-app/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@teamhubapp/firebase-app",
3-
"version": "0.1.0-dev12",
3+
"version": "0.1.0-beta4",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-app.js",
66
"scripts": {
@@ -19,14 +19,14 @@
1919
"author": "teamhub.dev",
2020
"license": "Apache-2.0",
2121
"bugs": {
22-
"url": "https://github.com/TeamHubApp/firebase-kotlin-multiplatform-sdk/issues"
22+
"url": "https://github.com/TeamHubApp/firebase-kotlin-sdk/issues"
2323
},
24-
"homepage": "https://github.com/TeamHubApp/firebase-kotlin-multiplatform-sdk",
24+
"homepage": "https://github.com/TeamHubApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@teamhubapp/firebase-common": "0.1.0-dev12",
26+
"@teamhubapp/firebase-common": "0.1.0-beta4",
2727
"firebase": "6.2.3",
28-
"kotlin": "1.3.61",
29-
"kotlinx-coroutines-core": "1.3.2"
28+
"kotlin": "1.3.70",
29+
"kotlinx-coroutines-core": "1.3.4"
3030
}
3131
}
3232

firebase-auth/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
`maven-publish`
88
}
99

10-
version = "0.1.0-dev"
10+
version = "0.1.0-beta"
1111

1212
android {
1313
compileSdkVersion(property("targetSdkVersion") as Int)
@@ -99,8 +99,8 @@ tasks {
9999
into.createNewFile()
100100
into.writeText(from.readText()
101101
.replace("require('firebase-", "require('@teamhubapp/firebase-")
102-
.replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@cachet/kotlinx-serialization-runtime')")
103-
)
102+
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@teamhub/kotlinx-serialization-runtime')")
103+
)
104104
}
105105
}
106106

firebase-auth/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@teamhubapp/firebase-auth",
3-
"version": "0.1.0-dev12",
3+
"version": "0.1.0-beta4",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-auth.js",
66
"scripts": {
@@ -19,14 +19,14 @@
1919
"author": "teamhub.dev",
2020
"license": "Apache-2.0",
2121
"bugs": {
22-
"url": "https://github.com/TeamHubApp/firebase-kotlin-multiplatform-sdk/issues"
22+
"url": "https://github.com/TeamHubApp/firebase-kotlin-sdk/issues"
2323
},
24-
"homepage": "https://github.com/TeamHubApp/firebase-kotlin-multiplatform-sdk",
24+
"homepage": "https://github.com/TeamHubApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@teamhubapp/firebase-app": "0.1.0-dev12",
26+
"@teamhubapp/firebase-app": "0.1.0-beta4",
2727
"firebase": "6.2.3",
28-
"kotlin": "1.3.61",
29-
"kotlinx-coroutines-core": "1.3.2"
28+
"kotlin": "1.3.70",
29+
"kotlinx-coroutines-core": "1.3.4"
3030
}
3131
}
3232

firebase-common/build.gradle.kts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ plugins {
44
id("com.android.library")
55
kotlin("multiplatform")
66
kotlin("native.cocoapods")
7-
kotlin("plugin.serialization") version "1.3.61"
7+
kotlin("plugin.serialization") version "1.3.70"
88
`maven-publish`
99
}
1010
repositories {
1111
mavenCentral()
1212
google()
1313
}
14-
version = "0.1.0-dev"
14+
version = "0.1.0-beta"
1515

1616
android {
1717
compileSdkVersion(property("targetSdkVersion") as Int)
@@ -47,6 +47,11 @@ kotlin {
4747
jvmTarget = "1.8"
4848
}
4949
}
50+
val test by compilations.getting {
51+
kotlinOptions {
52+
jvmTarget = "1.8"
53+
}
54+
}
5055
}
5156

5257
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
@@ -60,24 +65,24 @@ kotlin {
6065
sourceSets {
6166
val commonMain by getting {
6267
dependencies {
63-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.14.0")
68+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.20.0")
6469
}
6570
}
6671
val androidMain by getting {
6772
dependencies {
6873
api("com.google.firebase:firebase-common:19.2.0")
69-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0")
74+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
7075
}
7176
}
7277
val jsMain by getting {
7378
dependencies {
7479
// implementation(npm("firebase", "6.2.3"))
75-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.14.0")
80+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.20.0")
7681
}
7782
}
7883
val jvmMain by getting {
7984
dependencies {
80-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0")
85+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
8186
}
8287
kotlin.srcDir("src/androidMain/kotlin")
8388
}
@@ -89,7 +94,7 @@ kotlin {
8994
}
9095
val iosMain by getting {
9196
dependencies {
92-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.14.0")
97+
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.20.0")
9398
}
9499
}
95100
configure(listOf(iosArm64, iosX64)) {
@@ -119,7 +124,7 @@ tasks {
119124
into.createNewFile()
120125
into.writeText(from.readText()
121126
.replace("require('firebase-", "require('@teamhubapp/firebase-")
122-
.replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@cachet/kotlinx-serialization-runtime')")
127+
// .replace("require('kotlinx-serialization-kotlinx-serialization-runtime')", "require('@teamhubapp/kotlinx-serialization-runtime')")
123128
)
124129
}
125130
}

firebase-common/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@teamhubapp/firebase-common",
3-
"version": "0.1.0-dev14",
3+
"version": "0.1.0-beta6",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-common.js",
66
"scripts": {
@@ -24,9 +24,9 @@
2424
"homepage": "https://github.com/TeamHubApp/firebase-kotlin-multiplatform-sdk",
2525
"dependencies": {
2626
"firebase": "6.2.3",
27-
"kotlin": "1.3.61",
28-
"kotlinx-coroutines-core": "1.3.2",
29-
"@cachet/kotlinx-serialization-runtime": "0.14.0-rc.2"
27+
"kotlin": "1.3.70",
28+
"kotlinx-coroutines-core": "1.3.4",
29+
"kotlinx-serialization-kotlinx-serialization-runtime": "0.20.0"
3030
}
3131
}
3232

firebase-common/src/androidMain/kotlin/dev/teamhub/firebase/_decoders.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import kotlinx.serialization.SerialDescriptor
66
import kotlinx.serialization.StructureKind
77

88
actual fun FirebaseDecoder.structureDecoder(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeDecoder = when(desc.kind as StructureKind) {
9-
StructureKind.CLASS -> (value as Map<*, *>).let { map ->
9+
StructureKind.CLASS, StructureKind.OBJECT -> (value as Map<*, *>).let { map ->
1010
FirebaseClassDecoder(map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
1111
}
1212
StructureKind.LIST -> (value as List<*>).let {

firebase-common/src/androidMain/kotlin/dev/teamhub/firebase/_encoders.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ actual fun FirebaseEncoder.structureEncoder(desc: SerialDescriptor, vararg typeP
1010
StructureKind.LIST -> mutableListOf<Any?>()
1111
.also { value = it }
1212
.let { FirebaseCompositeEncoder(positiveInfinity) { _, index, value -> it.add(index, value) } }
13-
StructureKind.MAP, StructureKind.CLASS -> mutableMapOf<Any?, Any?>()
13+
StructureKind.MAP -> mutableListOf<Any?>()
14+
.let { FirebaseCompositeEncoder(positiveInfinity, { value = it.chunked(2).associate { (k, v) -> k to v } }) { _, _, value -> it.add(value) } }
15+
StructureKind.CLASS, StructureKind.OBJECT -> mutableMapOf<Any?, Any?>()
1416
.also { value = it }
1517
.let { FirebaseCompositeEncoder(positiveInfinity) { _, index, value -> it[desc.getElementName(index)] = value } }
1618
}
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
package dev.teamhub.firebase
22

33
import kotlinx.serialization.Serializable
4+
import kotlinx.serialization.builtins.ListSerializer
45
import kotlinx.serialization.serializer
56
import kotlin.test.Test
67
import kotlin.test.assertEquals
78

89
@Serializable
9-
data class TestData(val map: Map<String, String>)
10+
data class TestData(val map: Map<String, String>, val bool: Boolean = false)
1011

1112
class EncodersTest {
1213
@Test
1314
fun `encode a map`() {
14-
val encoded = encode<TestData>(TestData::class.serializer(), TestData(mapOf("key" to "value")))
15-
assertEquals(mapOf("key" to "value"), (encoded as Map<String, Any>)["map"])
15+
val encoded = encode(mapOf("key" to "value"))
16+
assertEquals(mapOf("key" to "value"), encoded)
17+
}
18+
19+
@Test
20+
fun `encode a class`() {
21+
val encoded = encode<TestData>(TestData::class.serializer(), TestData(mapOf("key" to "value"), true))
22+
assertEquals(mapOf("map" to mapOf("key" to "value"), "bool" to true), encoded)
23+
}
24+
25+
@Test
26+
fun `decode a class`() {
27+
val decoded = decode<TestData>(TestData::class.serializer(), mapOf("map" to mapOf("key" to "value")))
28+
assertEquals(TestData(mapOf("key" to "value"), false), decoded)
29+
}
30+
31+
@Test
32+
fun `decode a list of class`() {
33+
val decoded = decode(ListSerializer(TestData::class.serializer()), listOf(mapOf("map" to mapOf("key" to "value"))))
34+
assertEquals(listOf(TestData(mapOf("key" to "value"), false)), decoded)
1635
}
1736
}

0 commit comments

Comments
 (0)