-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.gradle
81 lines (70 loc) · 2.68 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import org.apache.tools.ant.taskdefs.condition.Os
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.nav_version = "2.7.7"
repositories {
google()
}
dependencies {
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'
}
}
plugins {
id 'com.android.application' version '8.3.2' apply false
id 'com.android.library' version '8.3.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id 'com.google.devtools.ksp' version '1.9.23-1.0.20' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
/**
* Module building tasks: These tasks build the Magisk module with the overlay stub.
* They are dynamic, copying the relevant files from the overlay module into app's assets when done.
*/
task cleanOverlay(type: Delete, dependsOn: ordered(':overlay:clean')) {
//Delete the previously built APK to start fresh
delete 'overlay/module/system/product/overlay/PixelLauncherModsOverlay.apk'
}
/**
* Using `:overlay:assembleRelease` does not seem to work from the Studio-embedded Gradle.
* Instead, we spawn a separate gradle for this small task.
*/
task assembleGradleDaemon(type: Exec) {
String gradleWrapper = ""
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
gradleWrapper = "gradlew.bat"
}else{
gradleWrapper = "./gradlew"
}
workingDir "$projectDir"
commandLine gradleWrapper, ':overlay:assembleRelease'
}
task buildAndCopyOverlay(type: Copy, dependsOn: ordered(':assembleGradleDaemon')) {
//Copy built APK into module folder
from "overlay/build/outputs/apk/release/overlay-release.apk"
into "overlay/module/system/product/overlay"
rename("overlay-release.apk", "PixelLauncherModsOverlay.apk")
}
task zipModule(type: Zip) {
//Zip up the module, copying it into the assets of the app
archiveFileName = "module.zip"
destinationDirectory = file("app/src/main/assets/overlay")
from "overlay/module"
}
task copyManifest(type: Copy) {
//Copy the current Manifest file into the assets for dynamic building
from "overlay/src/main/AndroidManifest.xml"
into "app/src/main/assets/overlay/build"
}
task createModule(dependsOn: ordered(':cleanOverlay', ':buildAndCopyOverlay', ':zipModule', ":copyManifest")) {
println "Building Module..."
}
def ordered(String... dependencyPaths) {
def dependencies = dependencyPaths.collect {tasks.getByPath(it) }
for (int i = 0; i < dependencies.size() - 1; i++) {
dependencies[i + 1].mustRunAfter(dependencies[i])
}
return dependencies
}