From ffceb5870543e4e6e13de9dfb4bd31e6642324f0 Mon Sep 17 00:00:00 2001 From: Teodor Grigor Date: Thu, 15 Feb 2024 17:21:59 +0200 Subject: [PATCH] Introduce :core:database package --- app/build.gradle.kts | 4 ++-- .../{data => core/database}/AppDatabase.kt | 17 ++++++++--------- .../{data => core/database}/dao/SavedGameDao.kt | 4 ++-- .../database}/dao/TestingKindDao.kt | 4 ++-- .../{data => core/database}/model/Difficulty.kt | 2 +- .../{data => core/database}/model/GameType.kt | 2 +- .../{data => core/database}/model/SavedGame.kt | 2 +- .../database}/model/SudokuEventType.kt | 2 +- .../database}/model/TestingKind.kt | 2 +- .../database/util}/Converters.kt | 8 ++++---- .../database/util}/DurationConverter.kt | 2 +- .../database/util}/ZonedDateTimeConverter.kt | 2 +- .../codegen/writers/OperationOutputWriter.kt | 6 +++--- .../writers/RepositoryImplOutputWriter.kt | 2 +- .../codegen/writers/RepositoryOutputWriter.kt | 4 ++-- .../codegen/writers/StitchModuleOutputWriter.kt | 4 ++-- 16 files changed, 33 insertions(+), 34 deletions(-) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/AppDatabase.kt (77%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/dao/SavedGameDao.kt (94%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/dao/TestingKindDao.kt (93%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/model/Difficulty.kt (98%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/model/GameType.kt (98%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/model/SavedGame.kt (97%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/model/SudokuEventType.kt (93%) rename app/src/main/kotlin/dev/teogor/stitch/{data => core/database}/model/TestingKind.kt (97%) rename app/src/main/kotlin/dev/teogor/stitch/{data/converters => core/database/util}/Converters.kt (84%) rename app/src/main/kotlin/dev/teogor/stitch/{data/converters => core/database/util}/DurationConverter.kt (96%) rename app/src/main/kotlin/dev/teogor/stitch/{data/converters => core/database/util}/ZonedDateTimeConverter.kt (97%) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 63afec6..b58f903 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,7 +25,7 @@ plugins { ksp { arg("stitch.addDocumentation", "true") arg("stitch.generateOperations", "true") - arg("stitch.generatedPackageName", "dev.teogor.stitch.database") + arg("stitch.generatedPackageName", "dev.teogor.stitch") } android { @@ -94,4 +94,4 @@ dependencies { implementation(project(":common")) ksp(project(":ksp")) -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/AppDatabase.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/AppDatabase.kt similarity index 77% rename from app/src/main/kotlin/dev/teogor/stitch/data/AppDatabase.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/AppDatabase.kt index 08abf9a..a16b35f 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/AppDatabase.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/AppDatabase.kt @@ -14,21 +14,20 @@ * limitations under the License. */ -package dev.teogor.stitch.data +package dev.teogor.stitch.core.database -// import dev.teogor.stitch.data.dao.GameWithBoardDao import android.content.Context import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase import androidx.room.TypeConverters -import dev.teogor.stitch.data.converters.Converters -import dev.teogor.stitch.data.converters.DurationConverter -import dev.teogor.stitch.data.converters.ZonedDateTimeConverter -import dev.teogor.stitch.data.dao.SavedGameDao -import dev.teogor.stitch.data.dao.TestingKindDao -import dev.teogor.stitch.data.model.SavedGame -import dev.teogor.stitch.data.model.TestingKind +import dev.teogor.stitch.core.database.util.Converters +import dev.teogor.stitch.core.database.util.DurationConverter +import dev.teogor.stitch.core.database.util.ZonedDateTimeConverter +import dev.teogor.stitch.core.database.dao.SavedGameDao +import dev.teogor.stitch.core.database.dao.TestingKindDao +import dev.teogor.stitch.core.database.model.SavedGame +import dev.teogor.stitch.core.database.model.TestingKind @Database( entities = [ diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/dao/SavedGameDao.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/dao/SavedGameDao.kt similarity index 94% rename from app/src/main/kotlin/dev/teogor/stitch/data/dao/SavedGameDao.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/dao/SavedGameDao.kt index d429352..11e7ffc 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/dao/SavedGameDao.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/dao/SavedGameDao.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.dao +package dev.teogor.stitch.core.database.dao import androidx.room.Dao import androidx.room.Delete @@ -22,7 +22,7 @@ import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query import androidx.room.Update -import dev.teogor.stitch.data.model.SavedGame +import dev.teogor.stitch.core.database.model.SavedGame import kotlinx.coroutines.flow.Flow @Dao diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/dao/TestingKindDao.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/dao/TestingKindDao.kt similarity index 93% rename from app/src/main/kotlin/dev/teogor/stitch/data/dao/TestingKindDao.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/dao/TestingKindDao.kt index f3df999..a1b6eec 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/dao/TestingKindDao.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/dao/TestingKindDao.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.dao +package dev.teogor.stitch.core.database.dao import androidx.room.Dao import androidx.room.Delete @@ -22,7 +22,7 @@ import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query import androidx.room.Update -import dev.teogor.stitch.data.model.SavedGame +import dev.teogor.stitch.core.database.model.SavedGame import kotlinx.coroutines.flow.Flow @Dao diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/model/Difficulty.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/Difficulty.kt similarity index 98% rename from app/src/main/kotlin/dev/teogor/stitch/data/model/Difficulty.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/model/Difficulty.kt index 1af8676..00fc0c0 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/model/Difficulty.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/Difficulty.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.model +package dev.teogor.stitch.core.database.model /** * Represents the difficulty levels of Sudoku puzzles. diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/model/GameType.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/GameType.kt similarity index 98% rename from app/src/main/kotlin/dev/teogor/stitch/data/model/GameType.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/model/GameType.kt index c2bb44a..fcdeb67 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/model/GameType.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/GameType.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.model +package dev.teogor.stitch.core.database.model // TODO get box size and row/col size diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/model/SavedGame.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/SavedGame.kt similarity index 97% rename from app/src/main/kotlin/dev/teogor/stitch/data/model/SavedGame.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/model/SavedGame.kt index 455cdc8..71253c6 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/model/SavedGame.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/SavedGame.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.model +package dev.teogor.stitch.core.database.model import androidx.room.ColumnInfo import androidx.room.Entity diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/model/SudokuEventType.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/SudokuEventType.kt similarity index 93% rename from app/src/main/kotlin/dev/teogor/stitch/data/model/SudokuEventType.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/model/SudokuEventType.kt index 0657f3c..477c5d3 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/model/SudokuEventType.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/SudokuEventType.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.model +package dev.teogor.stitch.core.database.model enum class SudokuEventType { Daily, diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/model/TestingKind.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/TestingKind.kt similarity index 97% rename from app/src/main/kotlin/dev/teogor/stitch/data/model/TestingKind.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/model/TestingKind.kt index 3517040..19d5076 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/model/TestingKind.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/model/TestingKind.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.model +package dev.teogor.stitch.core.database.model import androidx.room.ColumnInfo import androidx.room.Entity diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/converters/Converters.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/Converters.kt similarity index 84% rename from app/src/main/kotlin/dev/teogor/stitch/data/converters/Converters.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/util/Converters.kt index 3d40889..f1f3651 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/converters/Converters.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/Converters.kt @@ -14,12 +14,12 @@ * limitations under the License. */ -package dev.teogor.stitch.data.converters +package dev.teogor.stitch.core.database.util import androidx.room.TypeConverter -import dev.teogor.stitch.data.model.Difficulty -import dev.teogor.stitch.data.model.GameType -import dev.teogor.stitch.data.model.SudokuEventType +import dev.teogor.stitch.core.database.model.Difficulty +import dev.teogor.stitch.core.database.model.GameType +import dev.teogor.stitch.core.database.model.SudokuEventType object Converters { @TypeConverter diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/converters/DurationConverter.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/DurationConverter.kt similarity index 96% rename from app/src/main/kotlin/dev/teogor/stitch/data/converters/DurationConverter.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/util/DurationConverter.kt index 2dabdb1..1426e50 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/converters/DurationConverter.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/DurationConverter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.converters +package dev.teogor.stitch.core.database.util import androidx.room.TypeConverter import java.time.Duration diff --git a/app/src/main/kotlin/dev/teogor/stitch/data/converters/ZonedDateTimeConverter.kt b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/ZonedDateTimeConverter.kt similarity index 97% rename from app/src/main/kotlin/dev/teogor/stitch/data/converters/ZonedDateTimeConverter.kt rename to app/src/main/kotlin/dev/teogor/stitch/core/database/util/ZonedDateTimeConverter.kt index 18c9c06..e50bb68 100644 --- a/app/src/main/kotlin/dev/teogor/stitch/data/converters/ZonedDateTimeConverter.kt +++ b/app/src/main/kotlin/dev/teogor/stitch/core/database/util/ZonedDateTimeConverter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package dev.teogor.stitch.data.converters +package dev.teogor.stitch.core.database.util import androidx.room.TypeConverter import java.time.Instant diff --git a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/OperationOutputWriter.kt b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/OperationOutputWriter.kt index 6cef284..c91a9f5 100644 --- a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/OperationOutputWriter.kt +++ b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/OperationOutputWriter.kt @@ -77,7 +77,7 @@ class OperationOutputWriter( generatedClasses.forEach { (baseName, invokeFunctions) -> val className = "${room.name}${baseName.titleCase()}Operation" fileBuilder( - packageName = "${room.getPackageName()}.operations", + packageName = "${room.getPackageName()}.database.operation", fileName = className, ) { addType( @@ -88,7 +88,7 @@ class OperationOutputWriter( PropertySpec.builder( "repository", ClassName( - "${room.getPackageName()}.repository", + "${room.getPackageName()}.data.repository", "${room.name}Repository", ), ) @@ -101,7 +101,7 @@ class OperationOutputWriter( .addParameter( "repository", ClassName( - "${room.getPackageName()}.repository", + "${room.getPackageName()}.data.repository", "${room.name}Repository", ), ) diff --git a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryImplOutputWriter.kt b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryImplOutputWriter.kt index c33306a..ae2b6f5 100644 --- a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryImplOutputWriter.kt +++ b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryImplOutputWriter.kt @@ -40,7 +40,7 @@ class RepositoryImplOutputWriter( repositoryType: TypeName, ) { fileBuilder( - packageName = "${roomModel.getPackageName()}.repository.impl", + packageName = "${roomModel.getPackageName()}.data.repository.impl", fileName = "${roomModel.name}RepositoryImpl", ) { addType( diff --git a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryOutputWriter.kt b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryOutputWriter.kt index fe2f8b0..ac07c31 100644 --- a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryOutputWriter.kt +++ b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/RepositoryOutputWriter.kt @@ -37,7 +37,7 @@ class RepositoryOutputWriter( fun write(roomModel: RoomModel): TypeName { fileBuilder( - packageName = "${roomModel.getPackageName()}.repository", + packageName = "${roomModel.getPackageName()}.data.repository", fileName = "${roomModel.name}Repository", ) { addType( @@ -103,7 +103,7 @@ class RepositoryOutputWriter( }.writeWith(codeOutputStreamMaker) return ClassName( - "${roomModel.getPackageName()}.repository", + "${roomModel.getPackageName()}.data.repository", "${roomModel.name}Repository", ) } diff --git a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/StitchModuleOutputWriter.kt b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/StitchModuleOutputWriter.kt index e248076..c68d5d0 100644 --- a/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/StitchModuleOutputWriter.kt +++ b/codegen/src/main/kotlin/dev/teogor/stitch/codegen/writers/StitchModuleOutputWriter.kt @@ -133,7 +133,7 @@ class StitchModuleOutputWriter( .addAnnotation(DAGGER_PROVIDES) .returns( ClassName( - "${roomModel.getPackageName()}.repository", + "${roomModel.getPackageName()}.data.repository", "${roomModel.name}Repository", ), ) @@ -149,7 +149,7 @@ class StitchModuleOutputWriter( .addStatement( "return %T(dao)", ClassName( - "${roomModel.getPackageName()}.repository.impl", + "${roomModel.getPackageName()}.data.repository.impl", "${roomModel.name}RepositoryImpl", ), )