-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.gradle
87 lines (71 loc) · 2.9 KB
/
config.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
/**
* e.g:
* versionName: 1.4.1 build 3935, corresponding
* versionCode: 101 4 1 3935, remove space: 101413935
* indicates: version 1.4.1, week 39, wednesday, the 5th version packaged on this day.
*/
def VERSION_NAME = "1.0.2 build ${weekIndex()}${weekDay()}2"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.*/
def enableSeparateBuildPerCPUArchitecture = true
// 是否打印 build.gradle 脚本的一些输出。
def enableBuildScriptPrintln = true
ext {
android = [
compileSdk : 34,
buildTools : "34.0.0",
minSdk : 26,
targetSdk : 34,
versionCode: versionName2Code(VERSION_NAME),
versionName: VERSION_NAME,
zincVer : '1.8.0',
'jdkVer' : JavaVersion.VERSION_17
]
manifestPlaceholders = [
serverHost: "https://a.b.com",
//是否上架
onShelf : "false"
]
enableScriptPrint = enableBuildScriptPrintln
enablePerCpuArch = enableSeparateBuildPerCPUArchitecture
depends = [
'androidx.core' : "androidx.core:core:$ktx.Version",
'androidx.core.ktx': "androidx.core:core-ktx:$ktx.Version",
annoguard : 'com.github.bdo-cash:annoguard:v1.0.7',
'scalang' : 'com.github.bdo-cash:scala-lang:9ae46c9fd4', // scala 2.12
'reflow' : 'com.github.bdo-cash:reflow:v3.1.0', // scala 2.12
]
}
////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// //////////
static def versionName2Code(String versionName) {
// "0.9.4 build ${weekIndex()}${weekDay()}1"
def array = versionName.split("[\\s]+")
assert array.length == 3
def arr = array[0].split("\\.")
assert arr.length == 3
assert arr[1].length() == 1
assert arr[2].length() == 1
def minor = array[2].split("[\\D]+")[0]
String versionCode = String.valueOf(Integer.valueOf(arr[0]) + 100) +
arr[1] + arr[2] + String.format("%04d", Integer.valueOf(minor))
//println("versionCode:$versionCode")
return Integer.valueOf(versionCode)
}
static def weekIndex() {
Calendar calendar = Calendar.getInstance()
calendar.setFirstDayOfWeek(Calendar.MONDAY)
calendar.setMinimalDaysInFirstWeek(1)
return String.format("%02d", calendar.get(Calendar.WEEK_OF_YEAR))
}
static def weekDay() {
Calendar calendar = Calendar.getInstance()
calendar.setFirstDayOfWeek(Calendar.MONDAY)
calendar.setMinimalDaysInFirstWeek(1)
def dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1
if (dayOfWeek == 0) return 7 else return dayOfWeek
}