Skip to content

Commit

Permalink
fix: wrong use of dependency to revanced-patches
Browse files Browse the repository at this point in the history
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
  • Loading branch information
oSumAtrIX committed May 7, 2022
1 parent 52dacc1 commit 351de6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
6 changes: 0 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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:+")
Expand All @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions src/main/kotlin/app/revanced/patch/PatchLoader.kt

This file was deleted.

20 changes: 10 additions & 10 deletions src/main/kotlin/app/revanced/patch/Patches.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 351de6c

Please sign in to comment.