mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-11-19 01:59:25 +01:00
fix: wrong use of dependency to revanced-patches
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
52dacc16a0
commit
351de6cb90
@ -22,12 +22,9 @@ repositories {
|
||||
}
|
||||
}
|
||||
|
||||
val patchesDependency = "app.revanced:revanced-patches:1.+"
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
implementation("app.revanced:revanced-patcher:+")
|
||||
implementation(patchesDependency)
|
||||
implementation("info.picocli:picocli:+")
|
||||
|
||||
implementation("me.tongfei:progressbar:+")
|
||||
@ -45,9 +42,6 @@ tasks {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
shadowJar {
|
||||
dependencies {
|
||||
exclude(dependency(patchesDependency))
|
||||
}
|
||||
manifest {
|
||||
attributes("Main-Class" to "app.revanced.cli.MainKt")
|
||||
attributes("Implementation-Title" to project.name)
|
||||
|
@ -1,10 +0,0 @@
|
||||
package app.revanced.patch
|
||||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
internal class PatchLoader {
|
||||
internal companion object {
|
||||
|
||||
}
|
||||
}
|
@ -2,25 +2,25 @@ package app.revanced.patch
|
||||
|
||||
import app.revanced.patcher.data.base.Data
|
||||
import app.revanced.patcher.patch.base.Patch
|
||||
import app.revanced.patches.Index
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
internal object Patches {
|
||||
|
||||
|
||||
/**
|
||||
* This method loads patches from a given patch file
|
||||
* @return the loaded patches represented as a list of functions returning instances of [Patch]
|
||||
*/
|
||||
internal fun load(patchFile: File): List<() -> Patch<Data>> {
|
||||
val url = patchFile.toURI().toURL()
|
||||
internal fun load(patchesJar: File): List<() -> Patch<Data>> {
|
||||
val url = patchesJar.toURI().toURL()
|
||||
val classLoader = URLClassLoader(arrayOf(url))
|
||||
return loadIndex(classLoader).patches
|
||||
|
||||
val indexClass = classLoader.loadClass("app.revanced.patches.Index")
|
||||
|
||||
val index = indexClass.declaredFields.last()
|
||||
index.isAccessible = true
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return index.get(null) as List<() -> Patch<Data>>
|
||||
}
|
||||
private fun loadIndex(classLoader: ClassLoader) = classLoader
|
||||
.loadClass(Index::class.java.canonicalName)
|
||||
.fields
|
||||
.first()
|
||||
.get(null) as Index
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user