This repository has been archived by the owner on Dec 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
117 lines (90 loc) · 3.33 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'signing'
group 'me.kr328'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
def localProperties = new Properties();
localProperties.load(new FileReader("local.properties"))
repositories {
mavenCentral()
}
sourceSets {
main.compileClasspath += files("android-sdk/android.jar");
test.compileClasspath += files("android-sdk/android.jar");
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
}
task transformClassesWithDex(type: Exec) {
executable localProperties.get("android.sdk") + "/build-tools/" + localProperties.get("android.buildtools") + "/d8"
args += ["--output", "$buildDir/intermediate/dex/injector.jar", "--lib", "$projectDir/android-sdk/android.jar"]
setStandardOutput System.out
setErrorOutput System.err
doFirst {
file("$buildDir/intermediate/dex").mkdirs();
args += fileTree("$buildDir/classes/")
}
onlyIf {
return !classes.state.upToDate;
}
dependsOn(classes)
}
task buildNative(type: Exec) {
executable localProperties.get("android.ndk") + "/ndk-build"
args += ["NDK_LIBS_OUT=$buildDir/intermediate/native-libs", "NDK_OUT=$buildDir/intermediate/native-objs", "NDK_PROJECT_PATH=$projectDir/src/main/cpp"]
doLast {
file("$buildDir/intermediate/magisk-module/system").mkdirs()
}
}
task prepareMagiskModule {
doLast {
copy {
from file("$projectDir/src/main/raw/magisk-module-config/")
into file("$buildDir/intermediate/magisk-module/")
}
copy {
from file("$buildDir/intermediate/native-libs/")
into file("$buildDir/intermediate/magisk-module/loader/")
}
copy {
from file("$buildDir/intermediate/dex/")
into file("$buildDir/intermediate/magisk-module/")
}
}
dependsOn transformClassesWithDex, buildNative
}
task makeMagiskModule(type: Zip) {
from "$buildDir/intermediate/magisk-module/"
destinationDir file("$buildDir/outputs")
archiveName "magisk-module.zip"
dependsOn prepareMagiskModule
}
task signMagiskModule(type: Exec) {
executable localProperties.get("android.sdk") + "/build-tools/" + localProperties.get("android.buildtools") + "/apksigner"
args += ["sign" ,"--min-sdk-version" ,"24" ,"--max-sdk-version" ,"28"]
setStandardOutput System.out
setErrorOutput System.err
onlyIf {
def keystorePath = localProperties.get("sign.keystore")
def keystorePassword = localProperties.get("sign.keystore.password")
def alias = localProperties.get("sign.alias")
def aliasPassword = localProperties.get("sign.alias.password")
if ( keystorePath == null || keystorePassword == null || alias == null || aliasPassword == null )
return false
args += ["--ks" ,keystorePath ,"--ks-pass" ,"pass:" + keystorePassword ,"--ks-key-alias" ,alias ,"--key-pass" ,"pass:" + aliasPassword]
args += ["$buildDir/outputs/magisk-module.zip"]
return true
}
dependsOn makeMagiskModule
}
idea {
module {
inheritOutputDirs = false
outputDir = compileJava.destinationDir
testOutputDir = compileTestJava.destinationDir
}
}
assemble.dependsOn(transformClassesWithDex)
build.dependsOn(signMagiskModule)