mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-25 03:25:48 +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 {
|
dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
implementation("app.revanced:revanced-patcher:+")
|
implementation("app.revanced:revanced-patcher:+")
|
||||||
implementation(patchesDependency)
|
|
||||||
implementation("info.picocli:picocli:+")
|
implementation("info.picocli:picocli:+")
|
||||||
|
|
||||||
implementation("me.tongfei:progressbar:+")
|
implementation("me.tongfei:progressbar:+")
|
||||||
@ -45,9 +42,6 @@ tasks {
|
|||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
}
|
}
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependencies {
|
|
||||||
exclude(dependency(patchesDependency))
|
|
||||||
}
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes("Main-Class" to "app.revanced.cli.MainKt")
|
attributes("Main-Class" to "app.revanced.cli.MainKt")
|
||||||
attributes("Implementation-Title" to project.name)
|
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.data.base.Data
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patches.Index
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
|
|
||||||
internal object Patches {
|
internal object Patches {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method loads patches from a given patch file
|
* This method loads patches from a given patch file
|
||||||
* @return the loaded patches represented as a list of functions returning instances of [Patch]
|
* @return the loaded patches represented as a list of functions returning instances of [Patch]
|
||||||
*/
|
*/
|
||||||
internal fun load(patchFile: File): List<() -> Patch<Data>> {
|
internal fun load(patchesJar: File): List<() -> Patch<Data>> {
|
||||||
val url = patchFile.toURI().toURL()
|
val url = patchesJar.toURI().toURL()
|
||||||
val classLoader = URLClassLoader(arrayOf(url))
|
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