Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Use ReVanced Patches plugin #3446

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"README.md",
"CHANGELOG.md",
"gradle.properties",
"patches.json"
]
}
],
Expand All @@ -33,7 +32,7 @@
{
"assets": [
{
"path": "build/libs/revanced-patches*"
"path": "patches/build/libs/*.rvp"
}
],
successComment: false
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 `buildDexJar` task is used to build ReVanced Patches so that it can be used on Android.
The `publish` task depends on the `buildDexJar` task, so it will be run automatically when publishing a release.

## 📚 Everything else

Expand Down
6 changes: 0 additions & 6 deletions api/revanced-patches-template.api

This file was deleted.

137 changes: 0 additions & 137 deletions build.gradle.kts

This file was deleted.

7 changes: 7 additions & 0 deletions extensions/extension/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extension {
name = "extensions/extension.rve"
}

android {
namespace = "app.revanced.extension"
}
1 change: 1 addition & 0 deletions extensions/extension/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package app.revanced.extension;

public class ExampleExtension {
public static void get() {
// TODO("Not yet implemented")
}
}
16 changes: 4 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[versions]
revanced-patcher = "19.3.1"
smali = "3.0.7"
binary-compatibility-validator = "0.14.0"
kotlin = "2.0.0"

[libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
smali = { module = "com.android.tools.smali:smali", version.ref = "smali" }

[plugins]
binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
revanced-patcher = "20.0.0"
# Tracking https://github.com/google/smali/issues/64.
#noinspection GradleDependency
smali = "3.0.5"
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=544c35d6
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
4 changes: 4 additions & 0 deletions patches/api/patches.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public final class app/revanced/patches/example/ExamplePatchKt {
public static final fun getExamplePatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}

13 changes: 13 additions & 0 deletions patches/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package app.revanced.patches.example

import app.revanced.patcher.patch.bytecodePatch

@Suppress("unused")
val examplePatch = bytecodePatch(
name = "Example Patch",
description = "This is an example patch to start with.",
) {
compatibleWith("com.example.app"("1.0.0"))

extendWith("extensions/extension.rve")

execute {
// TODO("Not yet implemented")
}
}
19 changes: 16 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
}
20 changes: 0 additions & 20 deletions src/main/kotlin/app/revanced/patches/example/ExamplePatch.kt

This file was deleted.

Loading