diff --git a/build.gradle.kts b/build.gradle.kts index 7375b76ec..ca2ca1399 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,30 +2,31 @@ plugins { kotlin("jvm") version "1.9.0" } -group = "io.github.inotia00" +group = "app.revanced" + +val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR") +val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN") repositories { google() mavenCentral() mavenLocal() - maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") } maven { - url = uri("https://repo.sleeping.town") - content { - includeGroup("com.unascribed") + url = uri("https://maven.pkg.github.com/revanced/revanced-patcher") + credentials { + username = githubUsername + password = githubPassword } } } dependencies { - implementation("io.github.inotia00:revanced-patcher:11.0.6-SNAPSHOT") + implementation("app.revanced:revanced-patcher:14.2.2") implementation("com.android.tools.smali:smali:3.0.3") implementation("com.android.tools.smali:smali-dexlib2:3.0.3") // Required for meta implementation("com.google.code.gson:gson:2.10.1") - // Required for FlexVer-Java - implementation("com.unascribed:flexver-java:1.1.0") } tasks { diff --git a/src/main/kotlin/app/revanced/extensions/Extensions.kt b/src/main/kotlin/app/revanced/extensions/Extensions.kt index fa3cf899e..47881ca3b 100644 --- a/src/main/kotlin/app/revanced/extensions/Extensions.kt +++ b/src/main/kotlin/app/revanced/extensions/Extensions.kt @@ -1,8 +1,9 @@ package app.revanced.extensions +import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.extensions.MethodFingerprintExtensions.name import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import app.revanced.patcher.patch.PatchResultError +import app.revanced.patcher.patch.PatchException import app.revanced.patcher.util.proxy.mutableTypes.MutableClass import app.revanced.patcher.util.proxy.mutableTypes.MutableField import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod @@ -25,13 +26,13 @@ internal fun MutableMethodImplementation.injectHideCall( ) } -// TODO: populate this to all patches /** - * Convert a [MethodFingerprint] to a [PatchResultError]. + * Return [PatchException] from a [MethodFingerprint]. * - * @return A [PatchResultError] for the [MethodFingerprint]. + * @return The [PatchException] for the [MethodFingerprint]. */ -fun MethodFingerprint.toErrorResult() = PatchResultError("Failed to resolve $name") +val MethodFingerprint.exception + get() = PatchException("Failed to resolve $name") /** * Find the [MutableMethod] from a given [Method] in a [MutableClass]. @@ -65,6 +66,22 @@ fun MutableClass.transformFields(transform: MutableField.() -> MutableField) { fields.addAll(transformedFields) } +/** + * traverse the class hierarchy starting from the given root class + * + * @param targetClass the class to start traversing the class hierarchy from + * @param callback function that is called for every class in the hierarchy + */ +fun BytecodeContext.traverseClassHierarchy( + targetClass: MutableClass, + callback: MutableClass.() -> Unit +) { + callback(targetClass) + this.findClass(targetClass.superclass ?: return)?.mutableClass?.let { + traverseClassHierarchy(it, callback) + } +} + internal fun Node.doRecursively(action: (Node) -> Unit) { action(this) for (i in 0 until this.childNodes.length) this.childNodes.item(i).doRecursively(action) diff --git a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt b/src/main/kotlin/app/revanced/meta/JsonGenerator.kt index cebf57d91..3be7793f8 100644 --- a/src/main/kotlin/app/revanced/meta/JsonGenerator.kt +++ b/src/main/kotlin/app/revanced/meta/JsonGenerator.kt @@ -6,7 +6,6 @@ import app.revanced.patcher.extensions.PatchExtensions.description import app.revanced.patcher.extensions.PatchExtensions.include import app.revanced.patcher.extensions.PatchExtensions.options import app.revanced.patcher.extensions.PatchExtensions.patchName -import app.revanced.patcher.extensions.PatchExtensions.version import app.revanced.patcher.patch.PatchOption import com.google.gson.GsonBuilder import java.io.File @@ -17,7 +16,6 @@ internal class JsonGenerator : PatchesFileGenerator { JsonPatch( it.patchName, it.description ?: "This patch has no description.", - it.version ?: "0.0.0", !it.include, it.options?.map { option -> JsonPatch.Option( @@ -48,7 +46,6 @@ internal class JsonGenerator : PatchesFileGenerator { private class JsonPatch( val name: String, val description: String, - val version: String, val excluded: Boolean, val options: Array