forked from ReVanced/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import org.gradle.kotlin.dsl.support.listFilesOrdered | ||
|
||
plugins { | ||
kotlin("jvm") version "1.9.22" | ||
alias(libs.plugins.kotlin) | ||
alias(libs.plugins.binary.compatibility.validator) | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
group = "app.revanced" | ||
|
@@ -12,7 +13,14 @@ repositories { | |
mavenCentral() | ||
mavenLocal() | ||
google() | ||
maven { url = uri("https://jitpack.io") } | ||
maven { | ||
// A repository must be speficied for some reason. "registry" is a dummy. | ||
url = uri("https://maven.pkg.github.com/revanced/registry") | ||
credentials { | ||
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") | ||
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
@@ -28,61 +36,62 @@ kotlin { | |
jvmToolchain(11) | ||
} | ||
|
||
tasks.withType(Jar::class) { | ||
exclude("app/revanced/meta") | ||
|
||
manifest { | ||
attributes["Name"] = "ReVanced Patches" | ||
attributes["Description"] = "Patches for ReVanced." | ||
attributes["Version"] = version | ||
attributes["Timestamp"] = System.currentTimeMillis().toString() | ||
attributes["Source"] = "[email protected]:revanced/revanced-patches.git" | ||
attributes["Author"] = "ReVanced" | ||
attributes["Contact"] = "[email protected]" | ||
attributes["Origin"] = "https://revanced.app" | ||
attributes["License"] = "GNU General Public License v3.0" | ||
tasks { | ||
withType(Jar::class) { | ||
exclude("app/revanced/meta") | ||
|
||
manifest { | ||
attributes["Name"] = "ReVanced Patches" | ||
attributes["Description"] = "Patches for ReVanced." | ||
attributes["Version"] = version | ||
attributes["Timestamp"] = System.currentTimeMillis().toString() | ||
attributes["Source"] = "[email protected]:revanced/revanced-patches.git" | ||
attributes["Author"] = "ReVanced" | ||
attributes["Contact"] = "[email protected]" | ||
attributes["Origin"] = "https://revanced.app" | ||
attributes["License"] = "GNU General Public License v3.0" | ||
} | ||
} | ||
} | ||
|
||
tasks { | ||
register<DefaultTask>("generateBundle") { | ||
description = "Generate DEX files and add them in the JAR file" | ||
register("buildDexJar") { | ||
description = "Build and add a DEX to the JAR file" | ||
group = "build" | ||
|
||
dependsOn(build) | ||
|
||
doLast { | ||
val d8 = File(System.getenv("ANDROID_HOME")).resolve("build-tools") | ||
.listFilesOrdered().last().resolve("d8").absolutePath | ||
|
||
val artifacts = configurations.archives.get().allArtifacts.files.files.first().absolutePath | ||
val patchesJar = configurations.archives.get().allArtifacts.files.files.first().absolutePath | ||
val workingDirectory = layout.buildDirectory.dir("libs").get().asFile | ||
|
||
exec { | ||
workingDir = workingDirectory | ||
commandLine = listOf(d8, artifacts) | ||
commandLine = listOf(d8, patchesJar) | ||
} | ||
|
||
exec { | ||
workingDir = workingDirectory | ||
commandLine = listOf("zip", "-u", artifacts, "classes.dex") | ||
commandLine = listOf("zip", "-u", patchesJar, "classes.dex") | ||
} | ||
} | ||
} | ||
|
||
register<JavaExec>("generateMeta") { | ||
description = "Generate metadata for this bundle" | ||
register<JavaExec>("generatePatchesFiles") { | ||
description = "Generate patches files" | ||
|
||
dependsOn(build) | ||
|
||
classpath = sourceSets["main"].runtimeClasspath | ||
mainClass.set("app.revanced.meta.IPatchesFileGenerator") | ||
mainClass.set("app.revanced.generator.MainKt") | ||
} | ||
|
||
// Required to run tasks because Gradle semantic-release plugin runs the publish task. | ||
// Needed by gradle-semantic-release-plugin. | ||
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435 | ||
named("publish") { | ||
dependsOn("generateBundle") | ||
dependsOn("generateMeta") | ||
publish { | ||
dependsOn("buildDexJar") | ||
dependsOn("generatePatchesFiles") | ||
} | ||
} | ||
|
||
|
@@ -118,3 +127,9 @@ publishing { | |
} | ||
} | ||
} | ||
|
||
signing { | ||
useGpgCmd() | ||
|
||
sign(publishing.publications["revanced-patches-publication"]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package app.revanced.generator | ||
|
||
import app.revanced.patcher.PatchBundleLoader | ||
import java.io.File | ||
|
||
internal fun main() = PatchBundleLoader.Jar( | ||
File("build/libs/").listFiles { it -> it.name.endsWith(".jar") }!!.first(), | ||
).also { loader -> | ||
if (loader.isEmpty()) throw IllegalStateException("No patches found") | ||
}.let { bundle -> | ||
arrayOf(JsonPatchesFileGenerator()).forEach { generator -> generator.generate(bundle) } | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/app/revanced/generator/PatchesFileGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package app.revanced.generator | ||
|
||
import app.revanced.patcher.PatchSet | ||
|
||
internal interface PatchesFileGenerator { | ||
fun generate(patches: PatchSet) | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/kotlin/app/revanced/meta/IPatchesFileGenerator.kt
This file was deleted.
Oops, something went wrong.