-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
156 lines (129 loc) · 3.91 KB
/
build.gradle
File metadata and controls
156 lines (129 loc) · 3.91 KB
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
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
classpath 'org.ajoberstar:grgit:2.2.0'
}
}
configure(subprojects.findAll { it.path.startsWith(':apps:') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
signingKey(it)
versionProperties(it)
}
configure(subprojects.findAll { it.path.startsWith(':libraries:') }) {
if (!file("${projectDir}/build.gradle").exists())
return
apply plugin: 'com.android.library'
}
subprojects {
if (projectDir.toString().contains("mapfile"))
return
if (!file("${projectDir}/build.gradle").exists())
return
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 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 findLicenseProperties(project) {
def licenseDetails = project.file("license.properties")
if (!licenseDetails.exists() && (project.depth != 0))
return findLicenseProperties(project.parent)
return [licenseDetails, project]
} // findLicenseProperties
def signingKey(project) {
def (licenseDetails, projWithLicense) = findLicenseProperties(project)
if (!licenseDetails.exists()) {
println ":${project.name}:No license.properties"
return
}
Properties props = loadProperties(licenseDetails)
project.play {
track = 'beta'
}
project.android {
signingConfigs {
release {
storeFile projWithLicense.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 {
release {
signingConfig signingConfigs.release
}
}
}
}
repositories {
google()
}