Add shared module

This commit is contained in:
2020-11-12 10:25:02 +01:00
parent 151b4dbc76
commit 6ab63a7ddb
57 changed files with 929 additions and 617 deletions

124
shared/build.gradle.kts Normal file
View File

@@ -0,0 +1,124 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.android.library")
id("kotlin-android-extensions")
id("com.squareup.sqldelight")
}
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven {
url = uri("https://dl.bintray.com/kotlin/kotlin-eap")
}
}
kotlin {
android()
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
if (sdkName.startsWith("iphoneos")) {
iosArm64("ios") {
binaries {
framework {
baseName = "Shared"
}
}
}
} else {
iosX64("ios") {
binaries {
framework {
baseName = "Shared"
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(Dependencies.Kotlin.coroutinesCore)
// Ktor
implementation(Dependencies.Ktor.ktorCore)
implementation(Dependencies.Ktor.ktorJson)
implementation(Dependencies.Ktor.ktorSerialization)
// Serialization
implementation(Dependencies.Serialization.json)
// SqlDelight
implementation(Dependencies.SQLDelight.sqlDelightRuntime)
implementation(Dependencies.SQLDelight.sqlDelightCoroutines)
}
}
val androidMain by getting {
dependencies {
implementation(Dependencies.Kotlin.coroutinesAndroid)
// Ktor
implementation(Dependencies.Ktor.ktorOkhttp)
// SqlDelight
implementation(Dependencies.SQLDelight.sqlDelightAndroid)
// Misc
implementation(Dependencies.Misc.jsoup)
}
}
val iosMain by getting {
dependencies {
// Ktor
implementation(Dependencies.Ktor.ktorIos)
// SqlDelight
implementation(Dependencies.SQLDelight.sqlDelightNative)
}
}
}
}
android {
compileSdkVersion(Config.Android.compileSdk)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(Config.Android.minSdk)
targetSdkVersion(Config.Android.targetSdk)
versionCode = 1
versionName = "1.0"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
}
}
}
sqldelight {
database("AppDatabase") {
packageName = "net.underdesk.circolapp.shared.data"
sourceFolders = listOf("sqldelight")
}
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val targetName = "ios"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)