-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathprotect.gradle
62 lines (60 loc) · 2.24 KB
/
protect.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
ext {
// app相关的配置
app = [
//默认release apk的文件路径,因为加固是基于release包的
releasePath: "${project.buildDir}/outputs/apk/release",
//对release apk 加固后产生的加固apk地址
packersPath: "${project.buildDir}/outputs/packers",
]
// 360加固配置
packers = [account : '你的360加固包账号', //账号
password: '你的360加固包密码', //密码
jarPath : "../jiagu/jiagu.jar", //执行命令的jar包路径
]
}
//使用360加固命名结合Task进行打包
task protectApp() {
dependsOn("assembleRelease")
doLast {
println 'packers===beginning 360 jiagu'
def releaseApkDir = file(app["releasePath"])
def releaseApk = null
releaseApkDir.eachFile { file ->
if (file.isFile() && file.name.endsWith(".apk")) {
releaseApk = file
return
}
}
def packerDir = new File(app["packersPath"])
if (!packerDir.exists()) {
packerDir.mkdirs()
}
exec {
// 登录360加固保
executable = 'java'
args = ['-jar', packers["jarPath"], '-login', packers["account"], packers["password"]]
}
exec {
// 导入签名信息
executable = 'java'
args = ['-jar', packers["jarPath"], '-importsign', signing["storeFile"], signing["storePassword"], signing["keyAlias"], signing["keyPassword"]]
}
exec {
// 查看360加固签名信息
executable = 'java'
args = ['-jar', packers["jarPath"], '-showsign']
}
exec {
// 初始化加固服务配置
executable = 'java'
args = ['-jar', packers["jarPath"], '-config']
}
exec {
// 执行加固,然后自动签名,若不采取自动签名,需要自己通过build-tools命令自己签名
executable = 'java'
args = ['-jar', packers["jarPath"], '-jiagu', releaseApk.absolutePath, app["packersPath"], '-autosign']
}
println 'packers===360 jiagu finished'
println "packers===360 jiagu path ${app["packersPath"]}"
}
}