Skip to content

Commit

Permalink
Get rid of com.pubnub.kmp.PubNub (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkal-pubnub authored Jul 29, 2024
1 parent e8d77b5 commit 2d29625
Show file tree
Hide file tree
Showing 20 changed files with 670 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.creating
import org.gradle.kotlin.dsl.getting
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.DokkaDefaults.moduleName
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
Expand Down Expand Up @@ -43,7 +46,6 @@ class PubNubKotlinMultiplatformPlugin : Plugin<Project> {

listOf(
iosArm64(),
// iosX64(),
iosSimulatorArm64(),
).forEach {
it.binaries {
Expand All @@ -52,6 +54,22 @@ class PubNubKotlinMultiplatformPlugin : Plugin<Project> {
}
}
}
applyDefaultHierarchyTemplate()
with (sourceSets) {
val commonMain = getByName("commonMain")

val nonJvm = create("nonJvm") {
it.dependsOn(commonMain)
}

val jsMain = getByName("jsMain") {
it.dependsOn(nonJvm)
}

val iosMain = getByName("iosMain") {
it.dependsOn(nonJvm)
}
}

(this as? ExtensionAware)?.extensions?.configure<CocoapodsExtension> {
ios.deploymentTarget = "14"
Expand Down
1 change: 0 additions & 1 deletion pubnub-core/pubnub-core-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ kotlin {
}
}
}

3 changes: 0 additions & 3 deletions pubnub-core/pubnub-core-api/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="build.gradle.kts">
<error line="36" column="1" source="standard:no-consecutive-blank-lines" />
</file>
</baseline>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import kotlin.test.Test
import kotlin.test.assertEquals

class JsonElementTest {

@Test
fun asList() {
val list = listOf("abc", "def")
val jsonList = createJsonElement(list.map { createJsonElement(it) })
val jsonList = createJsonElement(list)

assertEquals(list, jsonList.asList()?.map { it.asString() })
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ actual abstract class JsonElement(val value: Any?) {
}

override fun toString(): String {
return "JSONElement(${value.toString()})"
return "JSONElement($value)"
}
}

Expand Down
4 changes: 2 additions & 2 deletions pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<error line="1484" column="9" source="standard:property-naming" />
</file>
<file name="src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt">
<error line="1117" column="5" source="standard:function-naming" />
<error line="1137" column="5" source="standard:function-naming" />
<error line="1116" column="5" source="standard:function-naming" />
<error line="1136" column="5" source="standard:function-naming" />
</file>
</baseline>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pubnub.kmp
package com.pubnub.api

import com.pubnub.api.callbacks.Listener
import com.pubnub.api.endpoints.DeleteMessages
Expand Down Expand Up @@ -71,8 +71,10 @@ import com.pubnub.api.v2.subscriptions.EmptyOptions
import com.pubnub.api.v2.subscriptions.Subscription
import com.pubnub.api.v2.subscriptions.SubscriptionOptions
import com.pubnub.api.v2.subscriptions.SubscriptionSet
import com.pubnub.kmp.CustomObject
import com.pubnub.kmp.Uploadable

interface PubNub {
expect interface PubNub {
val configuration: PNConfiguration

fun addListener(listener: EventListener)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pubnub.kmp

import com.pubnub.api.PubNub
import com.pubnub.api.models.consumer.PNStatus
import com.pubnub.api.models.consumer.pubsub.PNMessageResult
import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ import com.pubnub.internal.entities.UserMetadataImpl
import com.pubnub.internal.subscription.SubscriptionImpl
import com.pubnub.internal.subscription.SubscriptionSetImpl
import com.pubnub.kmp.CustomObject
import com.pubnub.kmp.PubNub
import com.pubnub.kmp.Uploadable
import kotlinx.cinterop.ExperimentalForeignApi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.pubnub.api.v2.callbacks

import cocoapods.PubNubSwift.PubNubEventListenerObjC
import com.pubnub.api.PubNub
import com.pubnub.api.models.consumer.pubsub.PNMessageResult
import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult
import com.pubnub.api.models.consumer.pubsub.PNSignalResult
import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult
import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult
import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult
import com.pubnub.kmp.PubNub
import kotlinx.cinterop.ExperimentalForeignApi

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.pubnub.api.v2.callbacks

import cocoapods.PubNubSwift.PubNubStatusListenerObjC
import com.pubnub.api.PubNub
import com.pubnub.api.callbacks.Listener
import com.pubnub.api.models.consumer.PNStatus
import com.pubnub.kmp.PubNub
import kotlinx.cinterop.ExperimentalForeignApi

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import cocoapods.PubNubSwift.PubNubSetMembershipResultObjC
import cocoapods.PubNubSwift.PubNubSetUUIDMetadataResultObjC
import cocoapods.PubNubSwift.PubNubStatusListenerObjC
import com.pubnub.api.JsonElementImpl
import com.pubnub.api.PubNub
import com.pubnub.api.PubNubException
import com.pubnub.api.PubNubImpl
import com.pubnub.api.enums.PNStatusCategory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ import com.pubnub.internal.v2.entities.ChannelImpl
import com.pubnub.internal.v2.subscriptions.SubscriptionSetImpl
import com.pubnub.kmp.CustomObject
import com.pubnub.kmp.Optional
import com.pubnub.kmp.PubNub
import com.pubnub.kmp.Uploadable
import com.pubnub.kmp.createJsObject
import com.pubnub.kmp.toJsMap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pubnub.kmp

import com.pubnub.api.JsonElementImpl
import com.pubnub.api.PubNub
import com.pubnub.api.PubNubImpl
import com.pubnub.api.enums.PNStatusCategory
import com.pubnub.api.models.consumer.PNStatus
Expand Down
Loading

0 comments on commit 2d29625

Please sign in to comment.