mirror of
https://github.com/ReVanced/revanced-patches-template.git
synced 2026-01-10 21:36:18 +00:00
build(Needs bump): Use ReVanced Patches Gradle plugin to configure the build system
This commit is contained in:
6
.github/workflows/build_pull_request.yml
vendored
6
.github/workflows/build_pull_request.yml
vendored
@@ -16,6 +16,12 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
|
||||
- name: Cache Gradle
|
||||
uses: burrunan/gradle-cache-action@v1
|
||||
|
||||
|
||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -20,6 +20,12 @@ jobs:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: "17"
|
||||
|
||||
- name: Cache Gradle
|
||||
uses: burrunan/gradle-cache-action@v1
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
"README.md",
|
||||
"CHANGELOG.md",
|
||||
"gradle.properties",
|
||||
"patches.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -33,7 +32,7 @@
|
||||
{
|
||||
"assets": [
|
||||
{
|
||||
"path": "build/libs/revanced-patches*"
|
||||
"path": "patches/build/libs/*.rvp"
|
||||
}
|
||||
],
|
||||
successComment: false
|
||||
|
||||
17
README.md
17
README.md
@@ -10,15 +10,15 @@ For an example repository, see [ReVanced Patches](https://github.com/revanced/re
|
||||
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)
|
||||
2. Set up the [build.gradle.kts](build.gradle.kts) file (Specifically, the [group of the project](build.gradle.kts#L11),
|
||||
[manifest attributes](build.gradle.kts#L44-L54), and the [POM](build.gradle.kts#L105-L128))
|
||||
2. Set up the [build.gradle.kts](patches/build.gradle.kts) file (Specifically, the [group of the project](patches/build.gradle.kts#L1),
|
||||
and the [About](patches/build.gradle.kts#L5-L11))
|
||||
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/)
|
||||
1. Add the private key as a secret named [GPG_PRIVATE_KEY](.github/workflows/release.yml#L43) to your repository
|
||||
2. Add the passphrase as a secret named [GPG_PASSPHRASE](.github/workflows/release.yml#L44) 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
|
||||
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#L49) 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)
|
||||
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
|
||||
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
|
||||
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
|
||||
- To build ReVanced Patches that can be used on Android, the [`buildDexJar`](build.gradle.kts#L50-L73) task must be run.
|
||||
The [`publish` task depends on the `buildDexJar`](build.gradle.kts#L78) task,
|
||||
so it will be run automatically when publishing a release.
|
||||
- The `buildAndroid` task is used to build ReVanced Patches so that it can be used on Android.
|
||||
The `publish` task depends on the `buildAndroid` task, so it will be run automatically when publishing a release.
|
||||
|
||||
## 📚 Everything else
|
||||
|
||||
|
||||
137
build.gradle.kts
137
build.gradle.kts
@@ -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"])
|
||||
}
|
||||
7
extensions/extension/build.gradle.kts
Normal file
7
extensions/extension/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
extension {
|
||||
name = "extensions/extension.rve"
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "app.revanced.extension"
|
||||
}
|
||||
1
extensions/extension/src/main/AndroidManifest.xml
Normal file
1
extensions/extension/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest/>
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.revanced.extension;
|
||||
|
||||
public class ExampleExtension {
|
||||
public static void get() {
|
||||
// TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
[versions]
|
||||
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
13
patches/build.gradle.kts
Normal 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"
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ val examplePatch = bytecodePatch(
|
||||
) {
|
||||
compatibleWith("com.example.app"("1.0.0"))
|
||||
|
||||
extendWith("extensions/extension.rve")
|
||||
|
||||
execute {
|
||||
// TODO("Not yet implemented")
|
||||
}
|
||||
@@ -1,7 +1,20 @@
|
||||
rootProject.name = "revanced-patches-template"
|
||||
|
||||
buildCache {
|
||||
local {
|
||||
isEnabled = "CI" !in System.getenv()
|
||||
pluginManagement {
|
||||
repositories {
|
||||
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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user