-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle
78 lines (68 loc) · 1.89 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import org.gradle.api.artifacts.*
group 'at.alladin.rmbt'
version '1.0-SNAPSHOT'
apply plugin: 'base' // To add "clean" task to the root project.
subprojects {
apply from: rootProject.file('common.gradle')
}
buildscript {
repositories {
jcenter()
mavenCentral()
//https://developer.android.com/studio/preview/features/new-android-plugin-migration.html
maven {
url 'https://maven.google.com'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
def getVersionNameFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
return stdout.toString().trim()
}
def getBranchFromGit() {
def stdoutBranch = new ByteArrayOutputStream()
exec {
commandLine 'git', 'symbolic-ref', '--short', 'HEAD'
standardOutput = stdoutBranch
// git symbolic-ref fails if HEAD is detached
ignoreExitValue true
}
return stdoutBranch.toString().trim()
}
def getHashFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "log", "--pretty=format:'%h'", "-n 1"
standardOutput = stdout
}
return stdout.toString().trim()
}
def getVersionCodeFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return stdout.toString().trim().toInteger()
}
def getDirtyFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
// git list all "dirty" (untracked, modified) files
commandLine 'git', 'status', '--porcelain'
standardOutput = stdout
}
//if there are any files, git is "dirty"
if (stdout.toString().length()>0)
return "true";
else
return "false";
}