database -> kts

This commit is contained in:
Milos Kozak 2023-10-16 16:49:40 +02:00
parent 6ada2afa0d
commit e614fa9343
9 changed files with 90 additions and 117 deletions

View file

@ -7,6 +7,7 @@ object Libs {
const val stdlibJdk8 = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin"
const val test = "org.jetbrains.kotlin:kotlin-test:$kotlin"
const val reflect = "org.jetbrains.kotlin:kotlin-reflect:$kotlin"
}
object KotlinX {
@ -39,6 +40,15 @@ object Libs {
const val uiAutomator = "androidx.test.uiautomator:uiautomator:2.2.0"
}
object Room {
private const val roomVersion = "2.5.2"
const val room = "androidx.room:room-ktx:$roomVersion"
const val compiler = "androidx.room:room-compiler:$roomVersion"
const val runtime = "androidx.room:room-runtime:$roomVersion"
const val rxJava3 = "androidx.room:room-rxjava3:$roomVersion"
const val testing = "androidx.room:room-testing:$roomVersion"
}
object Wear {
const val wear = "androidx.wear:wear:1.3.0"
@ -63,6 +73,7 @@ object Libs {
}
const val truth = "com.google.truth:truth:1.1.5"
const val gson = "com.google.code.gson:gson:2.10.1"
}
object Dagger {
@ -113,13 +124,11 @@ object Libs {
const val json = "org.json:json:20230618"
const val jsonAssert = "org.skyscreamer:jsonassert:1.5.0"
const val room = "2.5.2"
const val lifecycle = "2.6.2"
const val coroutines = "1.7.3"
const val activity = "1.8.0"
const val fragmentktx = "1.6.1"
const val ormLite = "4.46"
const val gson = "2.10.1"
const val nav = "2.7.4"
const val material = "1.10.0"
const val gridlayout = "1.0.0"

View file

@ -1,4 +1,3 @@
plugins {
id("com.android.library")
id("kotlin-android")

View file

@ -1,36 +0,0 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
}
apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
android {
namespace 'app.aaps.database.entities'
defaultConfig {
minSdkVersion 26 // for wear
}
buildFeatures {
buildConfig = false
}
}
dependencies {
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
api "androidx.core:core-ktx:$core_version"
kapt "androidx.room:room-compiler:$room_version"
api "androidx.room:room-ktx:$room_version"
}
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'app.aaps.database.annotations.DbOpenForTesting'
}

View file

@ -0,0 +1,25 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
id("kotlin-allopen")
id("android-module-dependencies")
id("all-open-dependencies")
id("test-dependencies")
}
android {
namespace = "app.aaps.database.entities"
defaultConfig {
minSdk = Versions.wearMinSdk // for wear
}
}
dependencies {
api(Libs.Kotlin.stdlibJdk8)
api(Libs.AndroidX.core)
api(Libs.AndroidX.Room.room)
kapt(Libs.AndroidX.Room.compiler)
}

View file

@ -1,52 +0,0 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
}
apply from: "${project.rootDir}/core/main/android_module_dependencies.gradle"
apply from: "${project.rootDir}/core/main/test_dependencies.gradle"
apply from: "${project.rootDir}/core/main/jacoco_global.gradle"
android {
namespace 'app.aaps.database.impl'
defaultConfig {
kapt {
arguments {
arg("room.incremental", "true")
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas")
}
}
dependencies {
implementation project(':database:entities')
api "androidx.core:core-ktx:$core_version"
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
api "io.reactivex.rxjava3:rxjava:$rxjava_version"
api "io.reactivex.rxjava3:rxandroid:$rxandroid_version"
api "io.reactivex.rxjava3:rxkotlin:$rxkotlin_version"
api "com.google.code.gson:gson:$gson_version"
api "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
/* Database schema export */
kapt "androidx.room:room-compiler:$room_version"
api "androidx.room:room-ktx:$room_version"
api "androidx.room:room-rxjava3:$room_version"
api "com.google.dagger:dagger-android:$dagger_version"
api "com.google.dagger:dagger-android-support:$dagger_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
}

View file

@ -0,0 +1,50 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
id("kotlin-allopen")
id("android-module-dependencies")
id("test-dependencies")
}
apply(from = "${project.rootDir}/core/main/jacoco_global.gradle")
android {
namespace = "app.aaps.database.impl"
defaultConfig {
kapt {
arguments {
arg("room.incremental", "true")
arg("room.schemaLocation", "$projectDir/schemas")
}
}
}
sourceSets {
getByName("androidTest").assets.srcDirs("$projectDir/schemas")
}
}
dependencies {
implementation(project(":database:entities"))
api(Libs.Kotlin.stdlibJdk8)
api(Libs.Kotlin.reflect)
api(Libs.AndroidX.core)
api(Libs.Rx.rxJava)
api(Libs.Rx.rxAndroid)
api(Libs.Rx.rxKotlin)
api(Libs.Google.gson)
api(Libs.AndroidX.Room.room)
api(Libs.AndroidX.Room.runtime)
api(Libs.AndroidX.Room.rxJava3)
kapt(Libs.AndroidX.Room.compiler)
api(Libs.Dagger.android)
api(Libs.Dagger.androidSupport)
androidTestImplementation(Libs.AndroidX.Room.testing)
}

View file

@ -1,15 +0,0 @@
package app.aaps.database.annotations
/**
* This is the actual annotation that makes the class open. Don't use it directly, only through [DbOpenForTesting]
* which has a NOOP replacement in production.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class DbOpenClass
/**
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
*/
@DbOpenClass
@Target(AnnotationTarget.CLASS)
annotation class DbOpenForTesting

View file

@ -1,7 +1,7 @@
package app.aaps.database.impl
import androidx.annotation.OpenForTesting
import app.aaps.database.ValueWrapper
import app.aaps.database.annotations.DbOpenForTesting
import app.aaps.database.entities.Bolus
import app.aaps.database.entities.BolusCalculatorResult
import app.aaps.database.entities.Carbs
@ -34,8 +34,9 @@ import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.roundToInt
@DbOpenForTesting
@Singleton class AppRepository @Inject internal constructor(
@OpenForTesting
@Singleton
class AppRepository @Inject internal constructor(
internal val database: AppDatabase
) {

View file

@ -1,8 +0,0 @@
package app.aaps.database.annotations
/**
* Annotate a class with [DbOpenForTesting] if it should be extendable for testing.
* In production the class remains final.
*/
@Target(AnnotationTarget.CLASS)
annotation class DbOpenForTesting