Skip to content

Commit

Permalink
convert data module to multiplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
soulesidibe committed Mar 31, 2022
1 parent 906e2a5 commit 02ef8e5
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 39 deletions.
27 changes: 0 additions & 27 deletions data/build.gradle

This file was deleted.

55 changes: 55 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
id("java-library")
kotlin("multiplatform")
}

apply {
from(file("$rootDir/gradle_tests_report.gradle.kts"))
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlin {
jvm()
ios {
binaries.framework {
baseName = "data"
}
}

sourceSets {
val commonMain by getting {
dependencies {
implementation(project(":shared"))
implementation(Deps.kotlin)
implementation(Deps.coroutines_core)
implementation(Deps.koin_core)
}
}

val commonTest by getting {
dependencies {
implementation(Deps.commonTest)
implementation(Deps.commonAnnotations)
}
}
}

}

//dependencies {
// implementation(project(":shared"))
// implementation(Deps.kotlin)
// implementation(Deps.coroutines_android)
// implementation(Deps.koin_core)
//
// testImplementation(Deps.junit)
// testImplementation(Deps.coroutines_test)
// testImplementation(Deps.hamcrest)
// testImplementation(Deps.mockito)
// testImplementation(Deps.mockk)
// testImplementation(Deps.koin_test)
//}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ package com.soulesidibe.data.datasource

import com.soulesidibe.data.model.TodoData
import kotlinx.coroutines.flow.Flow
import java.sql.SQLException
import kotlin.jvm.Throws

interface TodoLocalDataSource {

fun getAll(): Flow<List<TodoData>>

suspend fun getBy(id: String): TodoData?

@Throws(SQLException::class)
suspend fun insert(todo: TodoData): Boolean

@Throws(SQLException::class)
suspend fun remove(todo: TodoData)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.soulesidibe.data.model

data class TodoData(val id: String, val title: String)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.soulesidibe.domain.exception.NoTodosFoundException
import com.soulesidibe.domain.repository.TodoRepository
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import java.sql.SQLException

internal class TodoRepositoryImpl(
private val dataSource: TodoLocalDataSource
Expand All @@ -37,7 +36,7 @@ internal class TodoRepositoryImpl(
override suspend fun addOrUpdate(todoEntity: TodoEntity): Boolean {
try {
return dataSource.insert(todoEntity.toDb())
} catch (e: SQLException) {
} catch (e: Exception) {
throw CannotAddOrUpdateException
}

Expand All @@ -47,7 +46,7 @@ internal class TodoRepositoryImpl(
try {
dataSource.remove(todoEntity.toDb())
return true
} catch (e: SQLException) {
} catch (e: Exception) {
throw CannotRemoveTodoException
}
}
Expand Down
3 changes: 0 additions & 3 deletions data/src/main/java/com/soulesidibe/data/model/TodoData.kt

This file was deleted.

4 changes: 2 additions & 2 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ apply {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
Expand Down

0 comments on commit 02ef8e5

Please sign in to comment.