build(Needs bump): Use ReVanced Patches Gradle plugin to configure the build system

This commit is contained in:
oSumAtrIX
2024-07-18 04:30:10 +02:00
parent afde3145e6
commit 624a4964c1
13 changed files with 70 additions and 152 deletions

View File

@@ -16,6 +16,12 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Cache Gradle - name: Cache Gradle
uses: burrunan/gradle-cache-action@v1 uses: burrunan/gradle-cache-action@v1

View File

@@ -20,6 +20,12 @@ jobs:
persist-credentials: false persist-credentials: false
fetch-depth: 0 fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Cache Gradle - name: Cache Gradle
uses: burrunan/gradle-cache-action@v1 uses: burrunan/gradle-cache-action@v1

View File

@@ -24,7 +24,6 @@
"README.md", "README.md",
"CHANGELOG.md", "CHANGELOG.md",
"gradle.properties", "gradle.properties",
"patches.json"
] ]
} }
], ],
@@ -33,7 +32,7 @@
{ {
"assets": [ "assets": [
{ {
"path": "build/libs/revanced-patches*" "path": "patches/build/libs/*.rvp"
} }
], ],
successComment: false successComment: false

View File

@@ -10,15 +10,15 @@ For an example repository, see [ReVanced Patches](https://github.com/revanced/re
To start using this template, follow these steps: To start using this template, follow these steps:
1. [Create a new repository using this template](https://github.com/new?template_name=revanced-patches-template&template_owner=ReVanced) 1. [Create a new repository using this template](https://github.com/new?template_name=revanced-patches-template&template_owner=ReVanced)
2. Set up the [build.gradle.kts](build.gradle.kts) file (Specifically, the [group of the project](build.gradle.kts#L11), 2. Set up the [build.gradle.kts](patches/build.gradle.kts) file (Specifically, the [group of the project](patches/build.gradle.kts#L1),
[manifest attributes](build.gradle.kts#L44-L54), and the [POM](build.gradle.kts#L105-L128)) and the [About](patches/build.gradle.kts#L5-L11))
3. Update dependencies in the [libs.versions.toml](gradle/libs.versions.toml) file 3. Update dependencies in the [libs.versions.toml](gradle/libs.versions.toml) file
4. [Create a pass-phrased GPG master key and subkey](https://mikeross.xyz/create-gpg-key-pair-with-subkeys/) 4. [Create a pass-phrased GPG master key and subkey](https://mikeross.xyz/create-gpg-key-pair-with-subkeys/)
1. Add the private key as a secret named [GPG_PRIVATE_KEY](.github/workflows/release.yml#L43) to your repository 1. Add the private key as a secret named [GPG_PRIVATE_KEY](.github/workflows/release.yml#L48) to your repository
2. Add the passphrase as a secret named [GPG_PASSPHRASE](.github/workflows/release.yml#L44) to your repository 2. Add the passphrase as a secret named [GPG_PASSPHRASE](.github/workflows/release.yml#L49) to your repository
3. Add the fingerprint of the GPG subkey as a secret named [GPG_FINGERPRINT](.github/workflows/release.yml#L45) to your repository 3. Add the fingerprint of the GPG subkey as a secret named [GPG_FINGERPRINT](.github/workflows/release.yml#L50) to your repository
6. [Create a PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with [push access](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication) 6. [Create a PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) with [push access](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication)
1. Add it as a secret named [REPOSITORY_PUSH_ACCESS](.github/workflows/release.yml#L49) to your repository 1. Add it as a secret named [REPOSITORY_PUSH_ACCESS](.github/workflows/release.yml#L54) to your repository
7. Set up the [README.md](README.md) file[^1] (e.g, title, description, license, summary of the patches 7. Set up the [README.md](README.md) file[^1] (e.g, title, description, license, summary of the patches
that are included in the repository) that are included in the repository)
@@ -48,9 +48,8 @@ To develop and release ReVanced Patches using this template, some things need to
via the [release.yml](.github/workflows/release.yml) workflow, which is also responsible for generating the changelog via the [release.yml](.github/workflows/release.yml) workflow, which is also responsible for generating the changelog
and updating the version of ReVanced Patches. It is triggered by pushing to the `dev` or `main` branch. and updating the version of ReVanced Patches. It is triggered by pushing to the `dev` or `main` branch.
The workflow uses the `publish` task to publish the release of ReVanced Patches The workflow uses the `publish` task to publish the release of ReVanced Patches
- To build ReVanced Patches that can be used on Android, the [`buildDexJar`](build.gradle.kts#L50-L73) task must be run. - The `buildAndroid` task is used to build ReVanced Patches so that it can be used on Android.
The [`publish` task depends on the `buildDexJar`](build.gradle.kts#L78) task, The `publish` task depends on the `buildAndroid` task, so it will be run automatically when publishing a release.
so it will be run automatically when publishing a release.
## 📚 Everything else ## 📚 Everything else

View File

@@ -1,137 +0,0 @@
import org.gradle.kotlin.dsl.support.listFilesOrdered
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.binary.compatibility.validator)
`maven-publish`
signing
}
group = "app.revanced"
repositories {
mavenCentral()
mavenLocal()
google()
maven {
// A repository must be specified 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 {
implementation(libs.revanced.patcher)
implementation(libs.smali)
}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
java {
targetCompatibility = JavaVersion.VERSION_11
}
tasks {
withType(Jar::class) {
manifest {
attributes["Name"] = "ReVanced Patches template"
attributes["Description"] = "Patches template for ReVanced."
attributes["Version"] = version
attributes["Timestamp"] = System.currentTimeMillis().toString()
attributes["Source"] = "git@github.com:revanced/revanced-patches-template.git"
attributes["Author"] = "ReVanced"
attributes["Contact"] = "contact@revanced.app"
attributes["Origin"] = "https://revanced.app"
attributes["License"] = "GNU General Public License v3.0"
}
}
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 patchesJar = configurations.archives.get().allArtifacts.files.files.first().absolutePath
val workingDirectory = layout.buildDirectory.dir("libs").get().asFile
exec {
workingDir = workingDirectory
commandLine = listOf(d8, "--release", patchesJar)
}
exec {
workingDir = workingDirectory
commandLine = listOf("zip", "-u", patchesJar, "classes.dex")
}
}
}
// Needed by gradle-semantic-release-plugin.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
publish {
dependsOn("buildDexJar")
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/revanced/revanced-patches-template")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
create<MavenPublication>("revanced-patches-publication") {
from(components["java"])
pom {
name = "ReVanced Patches template"
description = "Patches template for ReVanced."
url = "https://revanced.app"
licenses {
license {
name = "GNU General Public License v3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
}
}
developers {
developer {
id = "ReVanced"
name = "ReVanced"
email = "contact@revanced.app"
}
}
scm {
connection = "scm:git:git://github.com/revanced/revanced-patches-template.git"
developerConnection = "scm:git:git@github.com:revanced/revanced-patches-template.git"
url = "https://github.com/revanced/revanced-patches-template"
}
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["revanced-patches-publication"])
}

View File

@@ -0,0 +1,7 @@
extension {
name = "extensions/extension.rve"
}
android {
namespace = "app.revanced.extension"
}

View File

@@ -0,0 +1 @@
<manifest/>

View File

@@ -0,0 +1,7 @@
package app.revanced.extension;
public class ExampleExtension {
public static void get() {
// TODO("Not yet implemented")
}
}

View File

@@ -1,3 +1,5 @@
[versions] [versions]
revanced-patcher = "20.0.0" revanced-patcher = "20.0.0"
smali = "3.0.7" # Tracking https://github.com/google/smali/issues/64.
#noinspection GradleDependency
smali = "3.0.5"

13
patches/build.gradle.kts Normal file
View File

@@ -0,0 +1,13 @@
group = "app.revanced"
patches {
about {
name = "ReVanced Patches template"
description = "Patches template for ReVanced"
source = "git@github.com:revanced/revanced-patches-template.git"
author = "ReVanced"
contact = "contact@revanced.app"
website = "https://revanced.app"
license = "GNU General Public License v3.0"
}
}

View File

@@ -9,6 +9,8 @@ val examplePatch = bytecodePatch(
) { ) {
compatibleWith("com.example.app"("1.0.0")) compatibleWith("com.example.app"("1.0.0"))
extendWith("extensions/extension.rve")
execute { execute {
// TODO("Not yet implemented") // TODO("Not yet implemented")
} }

View File

@@ -1,7 +1,20 @@
rootProject.name = "revanced-patches-template" rootProject.name = "revanced-patches-template"
buildCache { pluginManagement {
local { repositories {
isEnabled = "CI" !in System.getenv() gradlePluginPortal()
google()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/revanced/registry")
credentials {
username = providers.gradleProperty("gpr.user").orNull ?: System.getenv("GITHUB_ACTOR")
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GITHUB_TOKEN")
}
}
} }
} }
plugins {
id("app.revanced.patches") version "1.0.0-dev.4"
}