-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle
79 lines (71 loc) · 2.06 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
// 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:0.9.+'
}
}
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") == false
}
def getSonatypeRepositoryUrl() {
if (isReleaseBuild()) {
return "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
return "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
allprojects {
repositories {
mavenCentral()
}
/*
* Gets a property from a configuration file. That file should define the following properties:
* - storeFile
* - storePassword
* - keyAlias
* - keyPassword
*/
ext.getSigningProperties = {
def String path = System.getenv("ANDROID_PRIVATE_PROPERTIES_PATH")
def File file = new File(path + "/" + rootProject.name + "/keystore.properties");
def Properties properties = new Properties();
properties.load(new FileInputStream(file))
properties.put("storeFile", path + "/" + rootProject.name + "/project.keystore")
return properties;
}
}
println 'Building version #' + getAppVersionCode() + ' : ' + getAppVersionName()