-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
100 lines (83 loc) · 2.34 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
buildscript {
apply from: 'config.gradle'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
// Android 默认的编译工具库插件
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin.sdk"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
// Javadoc设定为UTF-8了
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
task aaASit(type: Exec) {
commandLine 'sh', '-c', 'python3 utils/pgy.py build sit'
executable "sh"
}
/**
* 生成版本的时间
*/
static def releaseTime() {
return new Date().format("yyyy_MMdd")
}
/**
* 生成VersionCode
*/
@SuppressWarnings("unused")
static def generateVersionCode() {
return new Date().format("yyyyMMdd")
}
/**
* 重命名Apk的方法
*/
@SuppressWarnings(["GrMethodMayBeStatic", "unused"])
def renameAPK(android, variant, output) {
def flavor = variant.productFlavors[0]
def flavorName
def versionName
if (flavor == null) {
flavorName = ""
versionName = android.defaultConfig.versionName
} else {
versionName = flavor.versionName
flavorName = flavor.name
}
if (versionName == null || versionName.toString() == "null") {
versionName = variant.versionName
}
if (versionName == null || versionName.toString() == "null") {
versionName = ""
}
def versionNameSuffix = variant.buildType.versionNameSuffix
if (versionNameSuffix.toString() == "null") {
versionNameSuffix = ""
}
def buildTypeName = variant.buildType.name
if (buildTypeName == "debug") {
buildTypeName = "dev"
} else if (buildTypeName == "release") {
buildTypeName = "prod"
}
if (flavorName == "" || flavorName == "null") {
output.outputFileName = "${APK_PREFIX}_${buildTypeName}_v${versionName}${versionNameSuffix}_${releaseTime()}.apk"
} else {
output.outputFileName = "${APK_PREFIX}_${buildTypeName}_${flavorName}_v${versionName}${versionNameSuffix}_${releaseTime()}.apk"
}
}