-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
46 lines (43 loc) · 1.64 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
//buildscript {
// dependencies {
// // 增加AGC插件配置,请您参见AGC插件依赖关系选择合适的AGC插件版本。
// classpath 'com.android.tools.build:gradle:4.2.2'
// }
//}
plugins {
// 这是新版的classpath加入方式
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
id 'maven-publish'
// id 'com.google.devtools.ksp' version '1.8.10-1.0.9' apply false
}
// 计算versionCode的值
static Integer calculateVersionCode(String vn) {
String[] splits = vn.split('\\.')
println("分割VersionName:" + splits)
long w = Integer.parseInt(splits[0]) * 10000
long b = Integer.parseInt(splits[1]) * 100
long g = Integer.parseInt(splits[2])
if (b > 9900 || g > 99) {
throw new Exception("版本号不符合规范: eg: 1.99.99 后两位必须为99以内数。")
}
return w + b + g
}
ext {
compileSdk = 33
minSdk = 21
targetSdk = 30
targetCompatibility = JavaVersion.VERSION_11
jvmTarget = "11"
/*
* versionName:低位最多两位数(100进1)最高位数不限位数。
* eg: 1.0.11, 1.22.33, 11.33.54, 111.10.23
* versionCode: 自动计算,无需关注!
* 注:versionName->>不能使用非数字的符号,比如[A-Za-z]$等,仅支持数字,仅支持两个点(.)]
* 升级时仅修改versionName就行了
*/
versionName = "5.0.0"
versionCode = calculateVersionCode(versionName)
}