mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-21 17:37:39 +00:00
Replace classindex with my own implementation that uses KSP instead of KAPT
This commit is contained in:
parent
ecb38f2518
commit
c3af9b03f6
@ -21,7 +21,7 @@ buildscript {
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.kapt)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.dependencyLicenseReport)
|
||||
alias(libs.plugins.compose.compiler)
|
||||
}
|
||||
@ -254,6 +254,10 @@ abstract class FixCollectionsClassVisitorFactory :
|
||||
interface Params : InstrumentationParameters
|
||||
}
|
||||
|
||||
ksp {
|
||||
arg("com.albertvaka.classindexksp.annotations", "org.kde.kdeconnect.Plugins.PluginFactory.LoadablePlugin")
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
variant.instrumentation.transformClassesWith(
|
||||
@ -307,8 +311,7 @@ dependencies {
|
||||
//implementation("com.github.bright:slf4android:0.1.6") { transitive = true } // For org.apache.sshd debugging
|
||||
implementation(libs.bcpkix.jdk15on) //For SSL certificate generation
|
||||
|
||||
implementation(libs.classindex)
|
||||
kapt(libs.classindex)
|
||||
ksp(libs.classindexksp)
|
||||
|
||||
// The android-smsmms library is the only way I know to handle MMS in Android
|
||||
// (Shouldn't a phone OS make phone things easy?)
|
||||
|
@ -5,7 +5,7 @@ androidGradlePlugin = "8.7.3"
|
||||
androidSmsmms = "kdeconnect-1-21-0"
|
||||
appcompat = "1.7.0"
|
||||
bcpkixJdk15on = "1.70"
|
||||
classindex = "3.13"
|
||||
classindexksp = "1.1"
|
||||
commonsCollections4 = "4.4"
|
||||
commonsIo = "2.17.0"
|
||||
commonsLang3 = "3.17.0"
|
||||
@ -18,6 +18,7 @@ gridlayout = "1.0.0"
|
||||
jsonassert = "1.5.3"
|
||||
junit = "4.13.2"
|
||||
kotlin = "2.0.21"
|
||||
kspPlugin = "2.0.21-1.0.28"
|
||||
kotlinxCoroutinesCore = "1.9.0"
|
||||
lifecycleExtensions = "2.2.0"
|
||||
lifecycleRuntimeKtx = "2.8.7"
|
||||
@ -58,7 +59,7 @@ androidx-preference-ktx = { module = "androidx.preference:preference-ktx", versi
|
||||
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
|
||||
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" }
|
||||
bcpkix-jdk15on = { module = "org.bouncycastle:bcpkix-jdk15on", version.ref = "bcpkixJdk15on" }
|
||||
classindex = { module = "org.atteo.classindex:classindex", version.ref = "classindex" }
|
||||
classindexksp = { module = "com.github.albertvaka:classindexksp", version.ref = "classindexksp" }
|
||||
commons-collections4 = { module = "org.apache.commons:commons-collections4", version.ref = "commonsCollections4" }
|
||||
commons-io = { module = "commons-io:commons-io", version.ref = "commonsIo" }
|
||||
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commonsLang3" }
|
||||
@ -87,5 +88,5 @@ slf4j-handroid = { group = "com.gitlab.mvysny.slf4j", name = "slf4j-handroid", v
|
||||
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
|
||||
ksp = { id = "com.google.devtools.ksp", version.ref = "kspPlugin" }
|
||||
dependencyLicenseReport = { id = "com.github.jk1.dependency-license-report", version.ref = "dependencyLicenseReport" }
|
||||
|
@ -3,11 +3,9 @@ pluginManagement {
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
/* Needed for org.apache.sshd debugging
|
||||
maven {
|
||||
url = uri("https://jitpack.io")
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
|
@ -8,17 +8,17 @@ package org.kde.kdeconnect.Plugins
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.annotation.DrawableRes
|
||||
import org.atteo.classindex.ClassIndex
|
||||
import org.atteo.classindex.IndexAnnotated
|
||||
import org.kde.kdeconnect.Device
|
||||
|
||||
object PluginFactory {
|
||||
annotation class LoadablePlugin //Annotate plugins with this so PluginFactory finds them
|
||||
|
||||
private var pluginInfo: Map<String, PluginInfo> = mapOf()
|
||||
|
||||
fun initPluginInfo(context: Context) {
|
||||
try {
|
||||
val plugins = ClassIndex.getAnnotated(LoadablePlugin::class.java)
|
||||
.map { it.newInstance() as Plugin }
|
||||
val plugins = com.albertvaka.classindexksp.LoadablePlugin
|
||||
.map { it.java.getDeclaredConstructor().newInstance() as Plugin }
|
||||
.map { plugin -> plugin.apply { setContext(context, null) } }
|
||||
|
||||
pluginInfo = plugins.associate { plugin -> Pair(plugin.pluginKey, PluginInfo(plugin)) }
|
||||
@ -45,7 +45,7 @@ object PluginFactory {
|
||||
|
||||
fun instantiatePluginForDevice(context: Context, pluginKey: String, device: Device): Plugin? {
|
||||
try {
|
||||
val plugin = pluginInfo[pluginKey]?.instantiableClass?.newInstance()?.apply { setContext(context, device) }
|
||||
val plugin = pluginInfo[pluginKey]?.instantiableClass?.getDeclaredConstructor()?.newInstance()?.apply { setContext(context, device) }
|
||||
return plugin
|
||||
} catch (e: Exception) {
|
||||
Log.e("PluginFactory", "Could not instantiate plugin: $pluginKey", e)
|
||||
@ -67,9 +67,6 @@ object PluginFactory {
|
||||
return used.map { it.key }.toSet()
|
||||
}
|
||||
|
||||
@IndexAnnotated
|
||||
annotation class LoadablePlugin //Annotate plugins with this so PluginFactory finds them
|
||||
|
||||
class PluginInfo private constructor(
|
||||
val displayName: String,
|
||||
val description: String,
|
||||
|
Loading…
x
Reference in New Issue
Block a user