forked from cyclestreets/android
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
173 lines (145 loc) · 4.43 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
buildscript {
ext.kotlinVersion = '1.2.60'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
classpath 'org.ajoberstar:grgit:2.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
configure(subprojects.findAll { it.path.startsWith(':custom-versions:') ||
it.path.startsWith(':cyclestreets') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
signingKey(it)
manifestProperties(it)
versionProperties(it)
}
configure(subprojects.findAll { it.path.startsWith(':libraries:') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.library'
}
subprojects {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'kotlin-android'
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
android {
Properties appConfig = loadProperties("${rootDir}/config.properties")
compileSdkVersion appConfig['compileSdkVersion'].toInteger()
buildToolsVersion appConfig['toolsVersion']
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion appConfig['minSdkVersion'].toInteger()
targetSdkVersion appConfig['targetSdkVersion'].toInteger()
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
// Required due to strictness of the Android developer tools. See lint.xml for full details.
lintOptions {
lintConfig rootProject.file('gradle/lint.xml')
}
}
}
def loadProperties(fileName) {
Properties props = new Properties()
props.load(new FileInputStream(file(fileName)))
return props
}
def manifestProperties(project) {
def cyclestreetsDetails = project.file("cyclestreets.properties")
if (!cyclestreetsDetails.exists()) {
println ":${project.name}:No cyclestreets.properties"
return
}
project.android {
buildTypes {
all {
manifestPlaceholders = loadProperties(cyclestreetsDetails)
}
}
}
}
def versionProperties(project) {
// Get the version name. We increment this manually after pushing beta releases to Production.
def versionProperties = project.file("version.properties")
def vName = loadProperties(versionProperties)['versionName']
// For the numerical version code, we use the number of commits on the branch. Since we don't
// intend to rewrite history on `master`, this will always be a monotonically increasing number.
def git = org.ajoberstar.grgit.Grgit.open()
def vCode = git.log().size()
println "Version name: ${vName}, code: ${vCode}"
project.android {
defaultConfig {
versionCode vCode
versionName vName
}
}
}
def signingKey(project) {
def licenseDetails = project.file("license.properties")
if (!licenseDetails.exists()) {
println ":${project.name}:No license.properties"
return
}
Properties props = loadProperties(licenseDetails)
project.play {
track = 'beta'
}
project.android {
signingConfigs {
release {
storeFile project.file(props['key.store'])
storePassword props['key.password']
keyAlias props['key.alias']
keyPassword props['key.password']
}
}
playAccountConfigs {
defaultAccountConfig {
serviceAccountEmail = 'cyclestreets-android@api-7698300952134656507-752021.iam.gserviceaccount.com'
pk12File = project.file('play-api-key.p12')
}
}
defaultConfig {
playAccountConfig = playAccountConfigs.defaultAccountConfig
}
buildTypes {
// If you have the decrypted keys locally, and need to use them to sign the debug variant so you can install it onto
// a real device for testing in advance of a beta build coming out, uncomment the following lines.
// debug {
// signingConfig signingConfigs.release
// }
release {
signingConfig signingConfigs.release
}
}
}
}
repositories {
google()
}