Skip to content

Commit

Permalink
Merge pull request #557 from igorescodro/amp/nit
Browse files Browse the repository at this point in the history
🧃 Improvements for the KMP modules
  • Loading branch information
igorescodro authored Aug 24, 2023
2 parents edf622a + 2e250a5 commit 2037002
Show file tree
Hide file tree
Showing 23 changed files with 287 additions and 444 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ out/
# Gradle files
.gradle/
build/
*(org.gradle.api.file.Directory

# Local configuration file (sdk path, etc)
local.properties
Expand Down
51 changes: 12 additions & 39 deletions data/datastore/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
import extension.commonDependencies
import extension.commonTestDependencies
import extension.setFrameworkBaseName

plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.escodro.kotlin-quality")
id("com.escodro.multiplatform")
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
setFrameworkBaseName("datastore")

android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
commonDependencies {
implementation(projects.data.repository)

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "datastore"
}
implementation(libs.koin.core)
implementation(libs.androidx.datastore)
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(projects.data.repository)

implementation(libs.koin.core)
implementation(libs.androidx.datastore)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
commonTestDependencies {
implementation(kotlin("test"))
}
}

android {
namespace = "com.escodro.datastore"
compileSdk = Integer.parseInt(libs.versions.android.sdk.compile.get())
defaultConfig {
minSdk = Integer.parseInt(libs.versions.android.sdk.min.get())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.escodro.datastore

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSDocumentDirectory
import platform.Foundation.NSFileManager
import platform.Foundation.NSURL
Expand All @@ -17,6 +18,7 @@ internal class IosDataStore {
*
* @return the [DataStore] instance
*/
@OptIn(ExperimentalForeignApi::class)
fun getDataStore(): DataStore<Preferences> = getDataStore(
producePath = {
val documentDirectory: NSURL? = NSFileManager.defaultManager.URLForDirectory(
Expand Down
73 changes: 22 additions & 51 deletions data/local/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,68 +1,39 @@
import extension.androidDependencies
import extension.commonDependencies
import extension.commonTestDependencies
import extension.iosDependencies
import extension.setFrameworkBaseName

plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.escodro.kotlin-quality")
id("com.escodro.multiplatform")
alias(libs.plugins.ksp)
alias(libs.plugins.sqldelight)
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
setFrameworkBaseName("local")

android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
commonDependencies {
implementation(projects.libraries.coroutines)
implementation(projects.data.repository)
implementation(libs.koin.core)
implementation(libs.kotlinx.datetime)
implementation(libs.sqldelight.coroutines)
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "local"
}
androidDependencies {
implementation(libs.sqldelight.driver)
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(projects.libraries.coroutines)
implementation(projects.data.repository)
implementation(libs.koin.core)
implementation(libs.kotlinx.datetime)
implementation(libs.sqldelight.coroutines)
}
}
val androidMain by getting {
dependencies {
implementation(libs.sqldelight.driver)
}
}
val iosMain by getting {
dependencies {
implementation(libs.sqldelight.native)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
}
}
iosDependencies {
implementation(libs.sqldelight.native)
}
commonTestDependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
}
}

android {
namespace = "com.escodro.local"
compileSdk = Integer.parseInt(libs.versions.android.sdk.compile.get())
defaultConfig {
minSdk = Integer.parseInt(libs.versions.android.sdk.min.get())
}
}

sqldelight {
Expand Down
53 changes: 13 additions & 40 deletions data/repository/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
import extension.commonDependencies
import extension.commonTestDependencies
import extension.setFrameworkBaseName

plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.escodro.kotlin-quality")
id("com.escodro.multiplatform")
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
setFrameworkBaseName("repository")

android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
commonDependencies {
implementation(projects.domain)

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "repository"
}
implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.datetime)
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(projects.domain)

implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.datetime)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
commonTestDependencies {
implementation(kotlin("test"))
}
}

android {
namespace = "com.escodro.repository"
compileSdk = Integer.parseInt(libs.versions.android.sdk.compile.get())
defaultConfig {
minSdk = Integer.parseInt(libs.versions.android.sdk.min.get())
}
}
57 changes: 15 additions & 42 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,54 +1,27 @@
import extension.commonDependencies
import extension.commonTestDependencies
import extension.setFrameworkBaseName

plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.escodro.kotlin-quality")
id("com.escodro.multiplatform")
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
targetHierarchy.default()
setFrameworkBaseName("domain")

android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
commonDependencies {
implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.logging)
implementation(libs.logback)
implementation(libs.kotlinx.datetime)
}

listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "domain"
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.logging)
implementation(libs.logback)
implementation(libs.kotlinx.datetime)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
}
}
commonTestDependencies {
implementation(kotlin("test"))
implementation(libs.kotlinx.coroutines.test)
}
}

android {
namespace = "com.escodro.domain"
compileSdk = Integer.parseInt(libs.versions.android.sdk.compile.get())
defaultConfig {
minSdk = Integer.parseInt(libs.versions.android.sdk.min.get())
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ compose_activity = "1.7.1"
compose_material3 = "1.0.1"
compose_icons = "1.4.2"
compose_windowsize = "1.0.1"
jb_compose_compiler = "1.4.3"

# Koin
koin_core = "3.4.3"
Expand Down Expand Up @@ -169,4 +170,5 @@ kotlin_serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
dependencyanalysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependencyanalysis" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
compose = {id = "org.jetbrains.compose", version.ref = "jb_compose_compiler" }

Binary file added ios-app/.DS_Store
Binary file not shown.
Loading

0 comments on commit 2037002

Please sign in to comment.