Skip to content

Commit ab47156

Browse files
hui.zhaohui.zhao
authored andcommitted
#Changed#
auto version
1 parent 2c7e055 commit ab47156

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app/build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
apply plugin: 'com.android.application'
22

3-
String[] version_part = String.valueOf(VERSION_NAME).split('\\.')
4-
5-
int VERSION_CODE = Integer.valueOf(version_part[0]) * 1000000 + Integer.valueOf(version_part[1]) * 1000 + Integer.valueOf(version_part[2])
6-
73
android {
84
signingConfigs {
95
release {
@@ -18,8 +14,8 @@ android {
1814
applicationId "cn.hikyson.godeyedemo"
1915
minSdkVersion 16
2016
targetSdkVersion 28
21-
versionCode VERSION_CODE
22-
versionName VERSION_NAME
17+
versionCode rootProject.ext.REAL_VERSION_CODE
18+
versionName rootProject.ext.REAL_VERSION_NAME
2319
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2420
}
2521
buildTypes {

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ allprojects {
2424
task clean(type: Delete) {
2525
delete rootProject.buildDir
2626
}
27+
28+
String[] versionPart = String.valueOf(VERSION_NAME).split('\\.')
29+
int realVersionCode = Integer.valueOf(versionPart[0]) * 1000000 + Integer.valueOf(versionPart[1]) * 1000 + Integer.valueOf(versionPart[2])
30+
31+
ext {
32+
REAL_VERSION_NAME = VERSION_NAME
33+
REAL_VERSION_CODE = realVersionCode
34+
}
35+
36+
println "[VERSION] Version name is [" + rootProject.ext.REAL_VERSION_NAME + "] and parsed version code is [" + rootProject.ext.REAL_VERSION_CODE + "]."

0 commit comments

Comments
 (0)