forked from dronekit/dronekit-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
63 lines (54 loc) · 1.77 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'io.fabric.tools:gradle:1.15.2'
}
}
def computeVersionCode(int versionMajor, int versionMinor, int versionPatch, int versionBuild = 0){
return versionMajor * 100000 + versionMinor * 1000 + versionPatch * 10 + versionBuild
}
def generateVersionName(String versionPrefix, int versionMajor, int versionMinor, int versionPatch, String versionSuffix = ""){
def versionName = "${versionPrefix}${versionMajor}.${versionMinor}.${versionPatch}"
if(versionSuffix != null && !versionSuffix.isEmpty() && versionSuffix != "release"){
versionName += "-${versionSuffix}"
}
return versionName
}
def generateVersionNameSuffix(int versionBuild, String releaseType){
return ".${releaseType}.${versionBuild} (${getGitShortHash()})"
}
/**
* @return The most recent git tag to be used as version name for the app.
*/
def getGitVersion() {
def cmd = "git describe --tag"
try {
def proc = cmd.execute()
return proc.text.trim()
} catch (IOException e) {
//Unable to find 'git'
return "please update version name manually"
}
}
def getGitShortHash(){
def cmd = "git rev-parse --short HEAD"
try{
def proc = cmd.execute()
return proc.text.trim()
} catch(IOException e){
//Unable to find git
return ""
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}