From 526c3a9c4d9868e59cac59ebe422357b301a7a11 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Sun, 13 Oct 2024 23:50:19 +0200 Subject: [PATCH] Replace ClassIndex (unmaintained) with KlassIndex --- build.gradle.kts | 8 ++++++-- gradle/libs.versions.toml | 5 +++-- src/org/kde/kdeconnect/Plugins/PluginFactory.kt | 15 ++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3fc7be84..f94d97a2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -267,6 +267,10 @@ androidComponents { } } +kapt { + useBuildCache = true +} + dependencies { // It has a bug that causes a crash when using PosixFilePermission and minSdk < 26. // It has been used in SSHD Core. @@ -307,8 +311,8 @@ 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) + implementation(libs.klassindex.library) + kapt(libs.klassindex.processor) // The android-smsmms library is the only way I know to handle MMS in Android // (Shouldn't a phone OS make phone things easy?) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 13404dea..5757cd2e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ androidGradlePlugin = "8.7.0" androidSmsmms = "kdeconnect-1-21-0" appcompat = "1.7.0" bcpkixJdk15on = "1.70" -classindex = "3.13" +klassindex = "4.1.0" commonsCollections4 = "4.4" commonsIo = "2.17.0" commonsLang3 = "3.17.0" @@ -58,7 +58,8 @@ 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" } +klassindex-library = { module = "fyi.fax.klassindex:library", version.ref = "klassindex" } +klassindex-processor = { module = "fyi.fax.klassindex:processor", version.ref = "klassindex" } 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" } diff --git a/src/org/kde/kdeconnect/Plugins/PluginFactory.kt b/src/org/kde/kdeconnect/Plugins/PluginFactory.kt index d12bc7ac..c04099ae 100644 --- a/src/org/kde/kdeconnect/Plugins/PluginFactory.kt +++ b/src/org/kde/kdeconnect/Plugins/PluginFactory.kt @@ -8,17 +8,21 @@ 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 fyi.fax.klassindex.KlassIndex +import fyi.fax.klassindex.IndexAnnotated import org.kde.kdeconnect.Device object PluginFactory { + + @IndexAnnotated + annotation class LoadablePlugin //Annotate plugins with this so PluginFactory finds them + private var pluginInfo: Map = mapOf() fun initPluginInfo(context: Context) { try { - val plugins = ClassIndex.getAnnotated(LoadablePlugin::class.java) - .map { it.newInstance() as Plugin } + val plugins = KlassIndex.getAnnotated(LoadablePlugin::class) + .map { it.java.getDeclaredConstructor().newInstance() as Plugin } .map { plugin -> plugin.apply { setContext(context, null) } } pluginInfo = plugins.associate { plugin -> Pair(plugin.pluginKey, PluginInfo(plugin)) } @@ -67,9 +71,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,