From db2804270e6a60376393ee9343ec2d8cd4691a66 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 2 Aug 2022 21:31:59 +0000 Subject: [PATCH 1/3] chore(release): 3.3.0 [skip ci] # [3.3.0](https://github.com/revanced/revanced-patcher/compare/v3.2.1...v3.3.0) (2022-08-02) ### Features * add getValue & setValue for PatchOption ([2572cd0](https://github.com/revanced/revanced-patcher/commit/2572cd04b5da4eeae738c8dde31493177edf0bf8)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf4cb81..7e760100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [3.3.0](https://github.com/revanced/revanced-patcher/compare/v3.2.1...v3.3.0) (2022-08-02) + + +### Features + +* add getValue & setValue for PatchOption ([2572cd0](https://github.com/revanced/revanced-patcher/commit/2572cd04b5da4eeae738c8dde31493177edf0bf8)) + ## [3.2.1](https://github.com/revanced/revanced-patcher/compare/v3.2.0...v3.2.1) (2022-08-02) diff --git a/gradle.properties b/gradle.properties index 45e40d89..7278d041 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ kotlin.code.style = official -version = 3.2.1 +version = 3.3.0 From 7b2d058144b0718992d329731e2af7cc704e4370 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 3 Aug 2022 03:45:34 +0200 Subject: [PATCH 2/3] fix: revert soft dependencies --- .../kotlin/app/revanced/patcher/Patcher.kt | 13 +++++---- .../extensions/AnnotationExtensions.kt | 27 +++++++------------ .../patch/annotations/PatchAnnotation.kt | 27 ++----------------- .../usage/bytecode/ExampleBytecodePatch.kt | 3 +-- 4 files changed, 18 insertions(+), 52 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index be387f65..38a0f425 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -262,16 +262,15 @@ class Patcher(private val options: PatcherOptions) { } // recursively apply all dependency patches - patch.dependencies.forEach { - val dependency = it.patch.java + patch.dependencies?.forEach { + val patchDependency = it.java - val result = applyPatch(dependency, appliedPatches) - if (result.isSuccess()) return@forEach + val result = applyPatch(patchDependency, appliedPatches) - val error = result.error()!! - val errorMessage = error.cause ?: error.message + if (result.isSuccess()) return@forEach - return PatchResultError("'$patchName' depends on '${dependency.patchName}' but the following error was raised: $errorMessage") + val errorMessage = result.error()!!.cause + return PatchResultError("'$patchName' depends on '${patchDependency.patchName}' but the following error was raised: $errorMessage") } val patchInstance = patch.getDeclaredConstructor().newInstance() diff --git a/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt b/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt index e5cf5de4..df7f8f5b 100644 --- a/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt +++ b/src/main/kotlin/app/revanced/patcher/extensions/AnnotationExtensions.kt @@ -7,9 +7,6 @@ import app.revanced.patcher.annotation.Version import app.revanced.patcher.data.Data import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint import app.revanced.patcher.patch.Patch -import app.revanced.patcher.patch.annotations.Dependencies -import app.revanced.patcher.patch.annotations.DependencyType -import app.revanced.patcher.patch.annotations.DependsOn import kotlin.reflect.KClass /** @@ -38,26 +35,20 @@ private fun Class<*>.findAnnotationRecursively( return null } -private typealias PatchClass = Class> - object PatchExtensions { - val PatchClass.patchName: String get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName - val PatchClass.version get() = recursiveAnnotation(Version::class)?.version - val PatchClass.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include - val PatchClass.description get() = recursiveAnnotation(Description::class)?.description - val PatchClass.dependencies get() = buildList { - recursiveAnnotation(DependsOn::class)?.let { add(PatchDependency(it.value, it.type)) } - recursiveAnnotation(Dependencies::class)?.dependencies?.forEach { add(PatchDependency(it, DependencyType.HARD)) } - }.toTypedArray() - val PatchClass.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages + val Class>.patchName: String + get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName + val Class>.version get() = recursiveAnnotation(Version::class)?.version + val Class>.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include + val Class>.description get() = recursiveAnnotation(Description::class)?.description + val Class>.dependencies get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.DependsOn::class)?.dependencies + val Class>.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages @JvmStatic - fun PatchClass.dependsOn(patch: PatchClass): Boolean { + fun Class>.dependsOn(patch: Class>): Boolean { if (this.patchName == patch.patchName) throw IllegalArgumentException("thisval and patch may not be the same") - return this.dependencies.any { it.patch.java.patchName == this@dependsOn.patchName } + return this.dependencies?.any { it.java.patchName == this@dependsOn.patchName } == true } - - class PatchDependency internal constructor(val patch: KClass>, val type: DependencyType = DependencyType.HARD) } object MethodFingerprintExtensions { diff --git a/src/main/kotlin/app/revanced/patcher/patch/annotations/PatchAnnotation.kt b/src/main/kotlin/app/revanced/patcher/patch/annotations/PatchAnnotation.kt index 409b34bf..12bdd208 100644 --- a/src/main/kotlin/app/revanced/patcher/patch/annotations/PatchAnnotation.kt +++ b/src/main/kotlin/app/revanced/patcher/patch/annotations/PatchAnnotation.kt @@ -19,29 +19,6 @@ annotation class Patch(val include: Boolean = true) @Target(AnnotationTarget.CLASS) @Retention(AnnotationRetention.RUNTIME) @MustBeDocumented -@Deprecated( - "Does not support new parameter 'type'", - ReplaceWith("DependsOn") -) -annotation class Dependencies( - val dependencies: Array>> = [] -) - -/** - * Annotation for dependencies of [Patch]es . - */ -@Target(AnnotationTarget.CLASS) -@Retention(AnnotationRetention.RUNTIME) -@MustBeDocumented -@Repeatable annotation class DependsOn( - val value: KClass>, - val type: DependencyType = DependencyType.HARD -) - -enum class DependencyType { - /** - * Enforces that the dependency is applied, even if it was not selected. - */ - HARD -} \ No newline at end of file + val dependencies: Array>> = [] +) \ No newline at end of file diff --git a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt index 29828f6e..6a31e628 100644 --- a/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt +++ b/src/test/kotlin/app/revanced/patcher/usage/bytecode/ExampleBytecodePatch.kt @@ -11,7 +11,6 @@ import app.revanced.patcher.patch.PatchOption import app.revanced.patcher.patch.PatchOptions import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResultSuccess -import app.revanced.patcher.patch.annotations.DependencyType import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.impl.BytecodePatch @@ -39,7 +38,7 @@ import org.jf.dexlib2.util.Preconditions @Description("Example demonstration of a bytecode patch.") @ExampleResourceCompatibility @Version("0.0.1") -@DependsOn(ExampleBytecodePatch::class, DependencyType.HARD) +@DependsOn([ExampleBytecodePatch::class]) class ExampleBytecodePatch : BytecodePatch(listOf(ExampleFingerprint)) { // This function will be executed by the patcher. // You can treat it as a constructor From 6c5f9d41987f0bd78ac838fd8dc071de754c991c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 3 Aug 2022 01:48:56 +0000 Subject: [PATCH 3/3] chore(release): 3.3.1 [skip ci] ## [3.3.1](https://github.com/revanced/revanced-patcher/compare/v3.3.0...v3.3.1) (2022-08-03) ### Bug Fixes * revert soft dependencies ([7b2d058](https://github.com/revanced/revanced-patcher/commit/7b2d058144b0718992d329731e2af7cc704e4370)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e760100..e83dcf97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.3.1](https://github.com/revanced/revanced-patcher/compare/v3.3.0...v3.3.1) (2022-08-03) + + +### Bug Fixes + +* revert soft dependencies ([7b2d058](https://github.com/revanced/revanced-patcher/commit/7b2d058144b0718992d329731e2af7cc704e4370)) + # [3.3.0](https://github.com/revanced/revanced-patcher/compare/v3.2.1...v3.3.0) (2022-08-02) diff --git a/gradle.properties b/gradle.properties index 7278d041..022f9a99 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ kotlin.code.style = official -version = 3.3.0 +version = 3.3.1