-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
111 lines (85 loc) · 2.75 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
//IMPORTANT: If you add dependencies here, you also need to mention
// the dependency in README.md. If you want it to show up in the application's about screen
// you also need to add it to the string array acknowledgements_Items in values/strings.xml
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'org.ajoberstar:gradle-git:1.1.0'
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'license'
import org.ajoberstar.grgit.*
def isTravisBuild() {
def tarvisVar = System.getenv('TRAVIS') ?: 'false'
return tarvisVar.compareToIgnoreCase('true') == 0
}
def getGitRepository() {
def repo = Grgit.open(dir: project.getRootProject().file('.'))
return repo
}
def getGitCommitId() {
if(isTravisBuild()) {
return System.getenv('TRAVIS_COMMIT') ?: 'Unknown'
} else {
def repo = getGitRepository()
def commitId = repo.head().getAbbreviatedId(10)
if(!repo.status().isClean()) {
commitId += "+"
}
return commitId
}
}
def getGitBranchName() {
if(isTravisBuild()) {
def prVar = System.getenv('TRAVIS_PULL_REQUEST') ?: 'false';
if(prVar.compareToIgnoreCase('false') == 0) {
return System.getenv('TRAVIS_BRANCH') ?: 'Unknown'
} else {
return 'Pull-Request ' + prVar + ' for Branch ' + System.getenv('TRAVIS_BRANCH') ?: ''
}
} else {
def repo = getGitRepository()
return repo.branch.getCurrent().getName()
}
}
def getGitCommitIdForCommonRepository() {
def repo = Grgit.open(dir: project.getRootProject().file('../kwikshop-common'))
def commitId = repo.head().getAbbreviatedId(10)
if(!repo.status().isClean()) {
commitId += "+"
}
return commitId
}
allprojects {
repositories {
jcenter()
}
// writes info from git to build/info.txt for each project
task writeBuildInfoFile() << {
def buildInfoFile = project.file("build/info.txt")
def buildInfo = "Commit: "
buildInfo <<= getGitCommitId()
buildInfo <<= "\n"
buildInfo <<= "Branch: "
buildInfo <<= getGitBranchName()
buildInfo <<= "\n"
buildInfoFile.text = buildInfo
}
}
license {
header = file('license.txt')
}
project(':app') {
dependencies {
project(':../kwikshop-common')
}
}