-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
128 lines (112 loc) · 3.2 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
118
119
120
121
122
123
124
125
126
127
128
import java.nio.charset.StandardCharsets
import java.text.SimpleDateFormat
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.1.1'
}
}
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
implementation project(":main")
}
def VERSION_NAME = "0.2.5"
def VERSION_CODE = 25
def THIRDS = [
dex2jar : "2.4",
aapt2 : "34.0.0",
android : "34",
apksigner : "34.0.0",
apktool : "2.9.3",
bundletool: "1.15.6",
zipalign : "34.0.0",
smail : "2.5.2",
backsmail : "2.5.2",
adb : "1.0.41"
]
application {
mainClass = 'com.coding.Main'
}
tasks.register('createProperties') {
doLast {
systemOut("createProperties start")
File dir = new File(projectDir, "main/src/main/resources/VERSION-INF")
if (!dir.exists()) {
dir.mkdirs()
}
String name = "adt.properties"
File out = new File(dir, name)
HashMap<String, Object> params = new HashMap<>()
params.put("versionName", VERSION_NAME)
params.put("versionCode", VERSION_CODE)
params.put("thirds", THIRDS)
params.put("data", getCurDate())
FileOutputStream fos = new FileOutputStream(out)
for (Map.Entry<String, Object> entry : params) {
String str = "${entry.key}=${entry.value}\n"
fos.write(str.getBytes(StandardCharsets.UTF_8))
}
fos.close()
systemOut("createProperties end")
}
}
tasks.register('release') {
dependsOn(createProperties)
dependsOn(assemble)
assemble.mustRunAfter(createProperties)
doLast {
systemOut("=>create release start...")
String dir = projectDir.absolutePath + File.separator + "release"
delete(dir)
String workspace = dir + File.separator + "workspace"
mkdir(workspace)
copy {
from "./build/libs/ADT-all.jar"
into workspace
systemOut("ADT.jar copy success")
}
copy {
from "./tools"
into workspace + File.separator + "tools"
systemOut("tools dir copy success")
}
createBootBat(workspace)
project.ant.zip(
basedir: workspace,
destfile: dir + File.separator + "ADT.zip"
)
delete(workspace)
systemOut("<=create release end...")
}
}
//获取当前日期
private static def getCurDate() {
def date = new Date()
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
return formatter.format(date)
}
//创建.bat启动文件
private static def createBootBat(String dir) {
File bat = new File(dir, "ADT.bat")
FileOutputStream fos = new FileOutputStream(bat)
fos.write("""@echo off
cd %0/..
@echo on
java -jar ADT-all.jar""".getBytes(StandardCharsets.UTF_8))
fos.flush()
fos.close()
}
private static def systemOut(String msg) {
println("----- $msg -----")
}