app: use room-compiler with ksp
authorDa Risk <da_risk@geekorum.com>
Thu, 04 May 2023 17:36:45 -0400
changeset 1032 fdca7174bdb7
parent 1031 c73798287874
child 1033 7e61ae8563c1
app: use room-compiler with ksp
app/build.gradle.kts
app/src/main/java/com/geekorum/ttrss/articles_list/FeedsRepository.kt
app/src/main/java/com/geekorum/ttrss/data/FeedsDao.kt
build.gradle.kts
gradle/libs.versions.toml
--- a/app/build.gradle.kts	Thu May 04 17:13:03 2023 -0400
+++ b/app/build.gradle.kts	Thu May 04 17:36:45 2023 -0400
@@ -31,6 +31,7 @@
 //    alias(libs.plugins.kotlin.kapt)
     kotlin("android")
     kotlin("kapt")
+    alias(libs.plugins.kotlin.ksp)
     alias(libs.plugins.google.gms.oss.license)
     id("com.geekorum.build.android-tests")
     id("com.geekorum.build.android-signing")
@@ -144,12 +145,17 @@
 
 kapt {
     arguments {
-        arg("room.schemaLocation", "$projectDir/schemas")
         // assisted inject create a module without hilt annotation. will be fixed in 0.5.3
         arg("dagger.hilt.disableModulesHaveInstallInCheck", true)
     }
 }
 
+ksp {
+    arg("room.schemaLocation", "$projectDir/schemas")
+    arg("room.incremental", "true")
+    arg("room.generateKotlin", "true")
+}
+
 
 dependencies {
 
@@ -239,7 +245,7 @@
     implementation(libs.androidx.hilt.navigation.compose)
 
 
-    kapt(libs.androidx.room.compiler)
+    ksp(libs.androidx.room.compiler)
     androidTestImplementation(libs.androidx.room.testing)
 
     androidTestImplementation(libs.androidx.work.testing)
--- a/app/src/main/java/com/geekorum/ttrss/articles_list/FeedsRepository.kt	Thu May 04 17:13:03 2023 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/articles_list/FeedsRepository.kt	Thu May 04 17:36:45 2023 -0400
@@ -35,13 +35,13 @@
 @Inject constructor(
     private val feedsDao: FeedsDao
 ) {
-    val allUnreadFeeds: Flow<List<Feed>> = feedsDao.allUnreadFeeds.map(this::addSpecialFeeds)
+    val allUnreadFeeds: Flow<List<Feed>> = feedsDao.getAllUnreadFeeds().map(this::addSpecialFeeds)
 
-    val allFeeds: Flow<List<Feed>> = feedsDao.allFeeds.map(this::addSpecialFeeds)
+    val allFeeds: Flow<List<Feed>> = feedsDao.getAllFeeds().map(this::addSpecialFeeds)
 
-    val allCategories: Flow<List<Category>> = feedsDao.allCategories
+    val allCategories: Flow<List<Category>> = feedsDao.getAllCategories()
 
-    val allUnreadCategories: Flow<List<Category>> = feedsDao.allUnreadCategories
+    val allUnreadCategories: Flow<List<Category>> = feedsDao.getAllUnreadCategories()
 
     fun getFeedById(feedId: Long): Flow<Feed?> {
         return when {
--- a/app/src/main/java/com/geekorum/ttrss/data/FeedsDao.kt	Thu May 04 17:13:03 2023 -0400
+++ b/app/src/main/java/com/geekorum/ttrss/data/FeedsDao.kt	Thu May 04 17:36:45 2023 -0400
@@ -34,20 +34,20 @@
 @Dao
 abstract class FeedsDao {
 
-    @get:Query("SELECT * FROM feeds WHERE unread_count > 0 ORDER BY title")
-    abstract val allUnreadFeeds: Flow<List<Feed>>
+    @Query("SELECT * FROM feeds WHERE unread_count > 0 ORDER BY title")
+    abstract fun getAllUnreadFeeds(): Flow<List<Feed>>
 
-    @get:Query("SELECT * FROM feeds ORDER BY title")
-    abstract val allFeeds: Flow<List<Feed>>
+    @Query("SELECT * FROM feeds ORDER BY title")
+    abstract fun getAllFeeds(): Flow<List<Feed>>
 
     @Query("SELECT * FROM feeds")
     internal abstract suspend fun getAllFeedsList(): List<Feed>
 
-    @get:Query("SELECT * FROM categories ORDER BY title")
-    abstract val allCategories: Flow<List<Category>>
+    @Query("SELECT * FROM categories ORDER BY title")
+    abstract fun getAllCategories(): Flow<List<Category>>
 
-    @get:Query("SELECT * FROM categories WHERE unread_count > 0 ORDER BY title")
-    abstract val allUnreadCategories: Flow<List<Category>>
+    @Query("SELECT * FROM categories WHERE unread_count > 0 ORDER BY title")
+    abstract fun getAllUnreadCategories(): Flow<List<Category>>
 
     @Query("SELECT * FROM categories")
     internal abstract suspend fun getAllCategoriesList(): List<Category>
--- a/build.gradle.kts	Thu May 04 17:13:03 2023 -0400
+++ b/build.gradle.kts	Thu May 04 17:36:45 2023 -0400
@@ -29,7 +29,8 @@
 //    alias(libs.plugins.kotlin.android) apply false
 //    alias(libs.plugins.kotlin.jvm) apply false
 //    alias(libs.plugins.kotlin.kapt) apply false
-    kotlin("plugin.serialization") version libs.versions.kotlin.get() apply false
+    kotlin("plugin.serialization") version libs.versions.kotlin.asProvider().get() apply false
+    alias(libs.plugins.kotlin.ksp) apply false
     // these should not be needed but for an unknown reason they get applied
     // with bad ordering if not there. or they can't be applied dynamically
     // version used is in gradle.properties
--- a/gradle/libs.versions.toml	Thu May 04 17:13:03 2023 -0400
+++ b/gradle/libs.versions.toml	Thu May 04 17:36:45 2023 -0400
@@ -65,6 +65,7 @@
 geekdroid = "geekttrss-1.6.3"
 aboutoss = "0.1.0"
 kotlin = "1.8.21"
+kotlin-ksp = "1.8.21-1.0.11"
 
 [plugins]
 # these cannot be used for now because it will use multiple classpath and will make play-publisher-plugin fail
@@ -79,6 +80,7 @@
 kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
 kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
 kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
+kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "kotlin-ksp" }
 
 [libraries]
 accompanist-insets-ui = { module = "com.google.accompanist:accompanist-insets-ui", version.ref = "accompanist" }