Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
chore: Refactor build files
Browse files Browse the repository at this point in the history
This commit improves the build files by using Gradle version catalogs and modernizes the Android build files. Additionally dependencies have been updated and some source files refactored.
  • Loading branch information
oSumAtrIX committed Feb 20, 2024
1 parent 6ee90ef commit 2cee15a
Show file tree
Hide file tree
Showing 40 changed files with 211 additions and 282 deletions.
15 changes: 5 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea
/.vscode
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
/.idea
/.vscode
/*.log
node_modules
local.properties
node_modules
2 changes: 1 addition & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build
/build
51 changes: 32 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin)
}

android {
compileSdk = 33
namespace = "app.revanced.integrations"
compileSdk = 33

applicationVariants.all {
outputs.all {
this as com.android.build.gradle.internal.api.ApkVariantOutputImpl

outputFileName = "${rootProject.name}-$versionName.apk"
}
}

defaultConfig {
applicationId = "app.revanced.integrations"
Expand All @@ -20,32 +28,37 @@ android {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
"proguard-rules.pro",
)
}
applicationVariants.all {
outputs.all {
this as com.android.build.gradle.internal.api.ApkVariantOutputImpl

outputFileName = "${rootProject.name}-$versionName.apk"
}
}
}

compileOptions {
sourceCompatibility(JavaVersion.VERSION_11)
targetCompatibility(JavaVersion.VERSION_11)
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}

dependencies {
compileOnly(project(mapOf("path" to ":dummy")))
compileOnly("androidx.annotation:annotation:1.7.0")
compileOnly("androidx.appcompat:appcompat:1.7.0-alpha03")
compileOnly("com.squareup.okhttp3:okhttp:5.0.0-alpha.11")
compileOnly("com.squareup.retrofit2:retrofit:2.9.0")
compileOnly(libs.appcompat)
compileOnly(libs.annotation)
compileOnly(libs.okhttp)
compileOnly(libs.retrofit)

compileOnly(project(":stub"))
}

tasks.register("publish") { dependsOn("build") }
tasks {
// Required to run tasks because Gradle semantic-release plugin runs the publish task.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
register("publish") {
group = "publishing"
description = "Publishes all publications produced by this project."

dependsOn(build)
}
}
23 changes: 1 addition & 22 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontobfuscate
-dontoptimize
-keepattributes * # https://www.guardsquare.com/manual/configuration/attributes
-keepattributes *
-keep class app.revanced.** {
*;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AppCompatActivityHook {
public static void startSettingsActivity() {
Logger.printDebug(() -> "Launching ReVanced settings");

final var context = app.revanced.integrations.shared.Utils.getContext();
final var context = Utils.getContext();

if (context != null) {
Intent intent = new Intent(context, SettingsActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ private static class VerifiedQualities {
private static final int CACHE_LIMIT = 1000;

@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
protected boolean removeEldestEntry(Entry eldest) {
return size() > CACHE_LIMIT; // Evict the oldest entry if over the cache limit.
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ private static boolean videoIdIsSame(@Nullable ReturnYouTubeDislike fetch, @Null
*
* Called when the user likes or dislikes.
*
* @param vote int that matches {@link ReturnYouTubeDislike.Vote#value}
* @param vote int that matches {@link Vote#value}
*/
public static void sendVote(int vote) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public final class ReturnYouTubeDislikeFilterPatch extends Filter {
private static final int NUMBER_OF_LAST_VIDEO_IDS_TO_TRACK = 5;

@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
protected boolean removeEldestEntry(Entry eldest) {
return size() > NUMBER_OF_LAST_VIDEO_IDS_TO_TRACK;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

public class Route {
private final String route;
private final Route.Method method;
private final Method method;
private final int paramCount;

public Route(Route.Method method, String route) {
public Route(Method method, String route) {
this.method = method;
this.route = route;
this.paramCount = countMatches(route, '{');
Expand All @@ -14,11 +14,11 @@ public Route(Route.Method method, String route) {
throw new IllegalArgumentException("Not enough parameters");
}

public Route.Method getMethod() {
public Method getMethod() {
return method;
}

public Route.CompiledRoute compile(String... params) {
public CompiledRoute compile(String... params) {
if (params.length != paramCount)
throw new IllegalArgumentException("Error compiling route [" + route + "], incorrect amount of parameters provided. " +
"Expected: " + paramCount + ", provided: " + params.length);
Expand All @@ -29,7 +29,7 @@ public Route.CompiledRoute compile(String... params) {
int paramEnd = compiledRoute.indexOf("}");
compiledRoute.replace(paramStart, paramEnd + 1, params[i]);
}
return new Route.CompiledRoute(this, compiledRoute.toString());
return new CompiledRoute(this, compiledRoute.toString());
}

public static class CompiledRoute {
Expand All @@ -45,7 +45,7 @@ public String getCompiledRoute() {
return compiledRoute;
}

public Route.Method getMethod() {
public Method getMethod() {
return baseRoute.method;
}
}
Expand Down
31 changes: 4 additions & 27 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.0.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20")
}
}

allprojects {
repositories {
google()
maven { url = uri("https://jitpack.io") }
mavenCentral()
}
}

// Tracking issue https://github.com/semantic-release/semantic-release/issues/963
tasks.register("publish", DefaultTask::class) {
group = "publish"
description = "Dummy publish to pass the verification phase of the gradle-semantic-release-plugin"
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin) apply false
}
4 changes: 0 additions & 4 deletions dummy/src/main/AndroidManifest.xml

This file was deleted.

18 changes: 18 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[versions]
agp = "8.2.2"
annotation = "1.7.1"
kotlin = "1.9.22"
appcompat = "1.7.0-alpha03"
okhttp = "5.0.0-alpha.12"
retrofit = "2.9.0"

[libraries]
annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dist
zipStorePath=wrapper/dists
Loading

0 comments on commit 2cee15a

Please sign in to comment.