-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathbuild.gradle
98 lines (88 loc) · 2.67 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
def getAppVersionName() {
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
def v = stdout.toString().trim()
if (v.contains("-") || !v.contains(".")) {
return v + '-SNAPSHOT'
} else {
return v
}
}
catch (ignored) {
return "0.0.0-SNAPSHOT";
}
}
def getAppVersionCode() {
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'develop'
standardOutput = code
}
return code.toString().trim().toInteger()
}
catch (ignored) {
return -1;
}
}
def isReleaseBuild() {
return !(getAppVersionName().contains("SNAPSHOT"))
}
def getSonatypeRepositoryUrl() {
if (isReleaseBuild()) {
return "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
return "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
def getSonatypeRepositoryUser() {
return hasProperty('sonatypeUser') ? sonatypeUser : ""
}
def getSonatypeRepositoryPassword() {
return hasProperty('sonatypePassword') ? sonatypePassword : ""
}
allprojects {
repositories {
mavenCentral()
}
/*
* Gets a property from a configuration file. That file should define the following properties:
* - storeFile
* - storePassword
* - keyAlias
* - keyPassword
*/
ext.getSigningProperties = {
def Properties properties = new Properties();
try {
def String path = System.getenv("ANDROID_PRIVATE_PROPERTIES_PATH")
def File file = new File(path + "/" + rootProject.name + "/keystore.properties");
properties.load(new FileInputStream(file))
properties.put("storeFile", path + "/" + rootProject.name + "/project.keystore")
properties.put("canSignRelease", true)
}
catch (ignored) {
// You can put your own properties here if you want
properties.put("storeFile", "")
properties.put("storePassword", "")
properties.put("keyAlias", "")
properties.put("keyPassword", "")
properties.put("canSignRelease", false)
}
return properties;
}
}
println 'Building version #' + getAppVersionCode() + ' : ' + getAppVersionName()