Merge pull request #1769 from FunkyMuse/feature/ksp_migration

feat: migrate to KSP and remove KAPT to improve build times
This commit is contained in:
Tibor Kaputa 2023-07-31 00:06:16 +02:00 committed by GitHub
commit 53ad279f5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 19 deletions

View file

@ -2,7 +2,6 @@ plugins {
alias(libs.plugins.android).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.kapt).apply(false)
alias(libs.plugins.parcelize).apply(false)
alias(libs.plugins.library).apply(false)
alias(libs.plugins.kotlinSerialization).apply(false)

View file

@ -1,7 +1,7 @@
plugins {
alias(libs.plugins.library)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.kapt)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlinSerialization)
alias(libs.plugins.parcelize)
`maven-publish`
@ -13,6 +13,9 @@ android {
defaultConfig {
minSdk = libs.versions.app.build.minimumSDK.get().toInt()
vectorDrawables.useSupportLibrary = true
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}
buildTypes {
@ -92,8 +95,8 @@ dependencies {
api(libs.gson)
api(libs.glide)
kapt(libs.glide.compiler)
ksp(libs.glide.compiler)
api(libs.bundles.room)
kapt(libs.androidx.room.compiler)
ksp(libs.androidx.room.compiler)
}

View file

@ -5,6 +5,7 @@ import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.simplemobiletools.commons.models.PhoneNumber
import com.simplemobiletools.commons.models.contacts.*
import java.util.ArrayList
class Converters {
private val gson = Gson()
@ -18,16 +19,16 @@ class Converters {
private val imType = object : TypeToken<List<IM>>() {}.type
@TypeConverter
fun jsonToStringList(value: String) = gson.fromJson<ArrayList<String>>(value, stringType)
fun jsonToStringList(value: String): ArrayList<String> = gson.fromJson(value, stringType)
@TypeConverter
fun stringListToJson(list: ArrayList<String>) = gson.toJson(list)
fun stringListToJson(list: ArrayList<String>): String = gson.toJson(list)
@TypeConverter
fun jsonToLongList(value: String) = gson.fromJson<ArrayList<Long>>(value, longType)
fun jsonToLongList(value: String): ArrayList<Long> = gson.fromJson(value, longType)
@TypeConverter
fun longListToJson(list: ArrayList<Long>) = gson.toJson(list)
fun longListToJson(list: ArrayList<Long>): String = gson.toJson(list)
// some hacky converting is needed since PhoneNumber model has been added to proguard rules, but obfuscated json was stored in database
// convert [{"a":"678910","b":2,"c":"","d":"678910","e":false}] to PhoneNumber(value=678910, type=2, label=, normalizedNumber=678910, isPrimary=false)
@ -48,29 +49,29 @@ class Converters {
}
@TypeConverter
fun phoneNumberListToJson(list: ArrayList<PhoneNumber>) = gson.toJson(list)
fun phoneNumberListToJson(list: ArrayList<PhoneNumber>): String = gson.toJson(list)
@TypeConverter
fun jsonToEmailList(value: String) = gson.fromJson<ArrayList<Email>>(value, emailType)
fun jsonToEmailList(value: String): ArrayList<Email> = gson.fromJson(value, emailType)
@TypeConverter
fun emailListToJson(list: ArrayList<Email>) = gson.toJson(list)
fun emailListToJson(list: ArrayList<Email>): String = gson.toJson(list)
@TypeConverter
fun jsonToAddressList(value: String) = gson.fromJson<ArrayList<Address>>(value, addressType)
fun jsonToAddressList(value: String): ArrayList<Address> = gson.fromJson(value, addressType)
@TypeConverter
fun addressListToJson(list: ArrayList<Address>) = gson.toJson(list)
fun addressListToJson(list: ArrayList<Address>): String = gson.toJson(list)
@TypeConverter
fun jsonToEventList(value: String) = gson.fromJson<ArrayList<Event>>(value, eventType)
fun jsonToEventList(value: String): ArrayList<Event> = gson.fromJson(value, eventType)
@TypeConverter
fun eventListToJson(list: ArrayList<Event>) = gson.toJson(list)
fun eventListToJson(list: ArrayList<Event>): String = gson.toJson(list)
@TypeConverter
fun jsonToIMsList(value: String) = gson.fromJson<ArrayList<IM>>(value, imType)
fun jsonToIMsList(value: String): ArrayList<IM> = gson.fromJson(value, imType)
@TypeConverter
fun IMsListToJson(list: ArrayList<IM>) = gson.toJson(list)
fun iMsListToJson(list: ArrayList<IM>): String = gson.toJson(list)
}

View file

@ -34,7 +34,7 @@ accompanist = "0.31.5-beta"
#Glide
glide = "4.15.1"
#Room
room = "2.5.2"
room = "2.6.0-alpha02"
#ezVcard
ezVcard = "0.11.3"
#gson
@ -139,5 +139,4 @@ ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
library = { id = "com.android.library", version.ref = "gradlePlugins-agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }