-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversioning.gradle
40 lines (37 loc) · 1.32 KB
/
versioning.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
ext {
versionMajor = 1
versionMinor = 1
versionPatch = 0
versionClassifier = null
isSnapshot = false
/**
* Builds an Android version code from the version of the project.
*
* I.e. when the application versionName is 3.1.0, the versionCode for a minimum API level 21 APK
* would be something like 21030100. The first two digits are reserved for the minimum
* API Level (21 in this case), and the last six digits are for the application’s version name (3.1.0).
*
* NOTE: The greatest value Google Play allows for versionCode is 2100000000
* @return
*/
buildVersionCode = {
(sdk.minSdk * 1000000) + (versionMajor * 10000) + (versionMinor * 100) + versionPatch
}
/**
* Builds an Android version name from the version of the project.
* This is designed to handle the -SNAPSHOT
*
* I.e. during development the version ends with -SNAPSHOT and the final release is without any suffix.
* @return
*/
buildVersionName = {
def versionName = "${versionMajor}.${versionMinor}.${versionPatch}"
if (versionClassifier == null && isSnapshot) {
versionClassifier = "SNAPSHOT"
}
if (versionClassifier != null) {
versionName += "-${versionClassifier}"
}
versionName
}
}