Skip to content

Commit 351de6c

Browse files
committed
fix: wrong use of dependency to revanced-patches
Signed-off-by: oSumAtrIX <[email protected]>
1 parent 52dacc1 commit 351de6c

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

build.gradle.kts

-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ repositories {
2222
}
2323
}
2424

25-
val patchesDependency = "app.revanced:revanced-patches:1.+"
26-
2725
dependencies {
2826
implementation(kotlin("stdlib"))
2927
implementation("app.revanced:revanced-patcher:+")
30-
implementation(patchesDependency)
3128
implementation("info.picocli:picocli:+")
3229

3330
implementation("me.tongfei:progressbar:+")
@@ -45,9 +42,6 @@ tasks {
4542
dependsOn(shadowJar)
4643
}
4744
shadowJar {
48-
dependencies {
49-
exclude(dependency(patchesDependency))
50-
}
5145
manifest {
5246
attributes("Main-Class" to "app.revanced.cli.MainKt")
5347
attributes("Implementation-Title" to project.name)

src/main/kotlin/app/revanced/patch/PatchLoader.kt

-10
This file was deleted.

src/main/kotlin/app/revanced/patch/Patches.kt

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ package app.revanced.patch
22

33
import app.revanced.patcher.data.base.Data
44
import app.revanced.patcher.patch.base.Patch
5-
import app.revanced.patches.Index
65
import java.io.File
76
import java.net.URLClassLoader
87

98
internal object Patches {
109

11-
1210
/**
1311
* This method loads patches from a given patch file
1412
* @return the loaded patches represented as a list of functions returning instances of [Patch]
1513
*/
16-
internal fun load(patchFile: File): List<() -> Patch<Data>> {
17-
val url = patchFile.toURI().toURL()
14+
internal fun load(patchesJar: File): List<() -> Patch<Data>> {
15+
val url = patchesJar.toURI().toURL()
1816
val classLoader = URLClassLoader(arrayOf(url))
19-
return loadIndex(classLoader).patches
17+
18+
val indexClass = classLoader.loadClass("app.revanced.patches.Index")
19+
20+
val index = indexClass.declaredFields.last()
21+
index.isAccessible = true
22+
23+
@Suppress("UNCHECKED_CAST")
24+
return index.get(null) as List<() -> Patch<Data>>
2025
}
21-
private fun loadIndex(classLoader: ClassLoader) = classLoader
22-
.loadClass(Index::class.java.canonicalName)
23-
.fields
24-
.first()
25-
.get(null) as Index
2626
}

0 commit comments

Comments
 (0)