Skip to content

Commit

Permalink
refactor dependency structure for new KMP version
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Dozor committed Jan 17, 2024
1 parent 75df5b7 commit 0fee51d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 50 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ android.enableJetifier=true
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
kotlin.mpp.enableCInteropCommonization=true
systemProp.org.gradle.internal.publish.checksums.insecure=true
kotlin.native.enableDependencyPropagation=false
kotlin.js.compiler=ir
IS_PUBLISHED=false

Expand Down
38 changes: 19 additions & 19 deletions smartype-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ kotlin {
browser()
}
jvm("jvm") {}
android("android") {
androidTarget("android") {
publishLibraryVariants("release")
}
ios() {
iosX64() {
binaries {
framework("SmartypeApi", listOf(RELEASE)) {

}
}
}
iosArm64() {
binaries {
framework("SmartypeApi", listOf(RELEASE)) {

}
}
}
iosSimulatorArm64() {
binaries {
framework("SmartypeApi", listOf(RELEASE)) {

Expand All @@ -41,33 +55,19 @@ kotlin {
}

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:${versions.serialization}")
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependsOn(commonMain)
}
val androidMain by getting {
dependsOn(jvmMain)
}

val jsMain by getting {
dependsOn(commonMain)
}

val iosMain by getting {
dependsOn(commonMain)
}
}
}
tasks {
Expand All @@ -83,7 +83,7 @@ android {
compileSdk = 31
defaultConfig {
minSdk = 19
targetSdk = 31
targetSdk = 33
}
sourceSets {
getByName("main") {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mparticle.smartype.api

public actual interface MessageReceiver {
public actual fun receive(message: String)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mparticle.smartype.api

public actual interface Serializable {
public actual fun toJson(): String
}
27 changes: 10 additions & 17 deletions smartype-receivers/smartype-mparticle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ kotlin {
js {
browser()
}
ios {
iosX64() {
binaries.framework()
}
iosArm64() {
binaries.framework()
}
iosSimulatorArm64() {
binaries.framework()
}

Expand All @@ -43,13 +49,13 @@ kotlin {
}

sourceSets {
val commonMain by getting {
commonMain {
dependencies {
api(project(":smartype-api"))
api("org.jetbrains.kotlinx:kotlinx-serialization-json:${versions.serialization}")
}
}
val commonTest by getting {
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test"))
Expand All @@ -58,24 +64,11 @@ kotlin {
}
}

val iosX64Main by getting {
dependsOn(commonMain)
}

val iosArm64Main by getting {
dependsOn(commonMain)
}

val androidMain by getting {
dependsOn(commonMain)
androidMain {
dependencies {
api(deps.mparticle.androidSdk)
}
}

val jsMain by getting {
dependsOn(commonMain)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import kotlinx.serialization.json.JsonPrimitive
import com.mparticle.smartype.api.receivers.mparticle.models.CustomEvent
import com.mparticle.smartype.api.receivers.mparticle.models.CustomEventType
import com.mparticle.smartype.api.receivers.mparticle.models.ScreenViewEvent
import kotlinx.cinterop.ExperimentalForeignApi
import kotlin.native.concurrent.freeze

@OptIn(ExperimentalForeignApi::class)
actual class MParticleReceiver : MessageReceiver {
override fun receive(message: String) {
val commonEvent = Converters.convertToEvent(message) ?: return
Expand Down
14 changes: 1 addition & 13 deletions smartype/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ kotlin {
}
pod("mParticle-Apple-SDK/mParticle"){
// Add these lines
linkOnly = true
extraOpts += listOf("-compiler-option", "-fmodules")
}
}
Expand Down Expand Up @@ -125,30 +126,17 @@ kotlin {
}
}

val androidMain by getting
if (androidMain != null) {
androidMain.dependsOn(commonMain)
}

try {
val jsMain by getting
if (jsMain != null) {
jsMain.dependsOn(commonMain)
}
} catch (e: kotlin.Exception) {
}

try {
val iosX64Main by getting {
dependsOn(commonMain)
kotlin.srcDir("src/iosMain")
}
} catch (e: kotlin.Exception) {
}

try {
val iosArm64Main by getting {
dependsOn(commonMain)
kotlin.srcDir("src/iosMain")
}
} catch (e: kotlin.Exception) {
Expand Down

0 comments on commit 0fee51d

Please sign in to comment.