-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.gradle
253 lines (227 loc) · 7.98 KB
/
common.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: '../dependencies.gradle'
apply from: '../shared_dependencies.gradle'
apply from: '../shared_test_dependencies.gradle'
apply from: '../sharedProperties.gradle'
// Loading key store credentials file
def keystorePropertiesFile = rootProject.file("keyStore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
// Loading private app properties
def appFile = rootProject.file("appProperties.properties")
def appProperties = new Properties()
appProperties.load(new FileInputStream(appFile))
// Generates Version Code based on date & Time
static def getVersionCode(offset = 0) {
def formattedDate = new Date().format('yyMMddHH')
return formattedDate.toInteger() + offset
}
android {
compileSdkVersion app.compileSdkVersion
buildToolsVersion app.buildToolsVersion
defaultConfig {
minSdkVersion app.minSdkVersion
targetSdkVersion app.targetSdkVersion
versionCode getVersionCode()
versionName app.applicationVersionName
testApplicationId app.applicationId
resValue "string", "app_name", "TV Series Finder"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [deepLinkScheme: appProperties['deepLinkScheme'],
deepLinkHost : appProperties['deepLinkHost']]
// to fix some compiling errors for roboelectric library
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
}
kotlinOptions {
jvmTarget = "1.8"
}
testOptions {
// reportDir "$rootDir/test-reports"
// resultsDir "$rootDir/test-results"
unitTests {
includeAndroidResources true
}
}
compileOptions {
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions 'version', 'region'
productFlavors {
eu {
dimension = "region"
resValue "string", "app_name", "TV Maze"
}
usa {
dimension = "region"
resValue "string", "app_name", "TV Maze Client"
}
development {
dimension = "version"
resConfigs "en", "xxhdpi"
// resValue "string", "app_name", "Development Project x"
manifestPlaceholders = [deepLinkScheme : "projectxdevscheme", deepLinkHost : "deep.project.x"]
// applicationId app.applicationId
// versionCode 1
// versionName '1.0.0'
}
play {
dimension = "version"
manifestPlaceholders = [deepLinkScheme : "projectxdevscheme", deepLinkHost : "deep.project.x"]
// resValue "string", "app_name", "Project x"
// applicationId app.applicationId
// versionCode 1
// versionName '1.0.0'
}
}
// Travers through different flavors and do some operations like ignoring unwanted flavors
// or adding some configuration stuff into that like build config, resValues, etc.
variantFilter { variant ->
def names = variant.flavors*.name
// To check for a build type instead, use variant.buildType.name == "buildType"
if (names.contains("demo") || names.contains("mena")) {
// Gradle ignores any variants that satisfy the conditions above.
setIgnore(true)
}
}
// Sign in credentials
// To change Sign in credentials go to keyStore.properties
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
buildConfigField("String", "BASE_URL", "${appProperties['releaseBaseUrl']}")
}
debug {
buildConfigField("String", "BASE_URL", "${appProperties['debugBaseUrl']}")
// ext.alwaysUpdateBuildId = false
debuggable true
}
}
// Avoids multiple APKs on debug mode and some other settings to speed up build
// if (project.hasProperty("devDebug") || project.hasProperty("demoDebug") || project.hasProperty("playDebug")) {
// splits.api.splits = false
// splits.density.splits = false
// aaptOptions.cruncherEnabled = false //disable crunching
// }
}
//import java.io.FileInputStream
//import java.util.*
//
//plugins {
// id("com.android.application")
// kotlin("android")
// kotlin("android.extensions")
// kotlin("kapt")
// id("../shared_dependencies.gradle")
// id("../shared_test_dependencies.gradle")
// id("../sharedProperties.gradle")
//}
//
//// Loading key store credentials file
//val fis = FileInputStream("keyStore.properties")
//val keystoreProperties = Properties()
//keystoreProperties.load(fis)
//
//// Loading private app properties
//val appFile = FileInputStream("appProperties.properties")
//val appProperties = Properties()
//appProperties.load(appFile)
//
//android {
// compileSdkVersion(AndroidConfig.COMPILE_SDK_VERSION)
// buildToolsVersion(AndroidConfig.BUILD_TOOLS_VERSION)
// defaultConfig {
// applicationId = AndroidConfig.ID
// minSdkVersion(AndroidConfig.MIN_SDK_VERSION)
// targetSdkVersion(AndroidConfig.TARGET_SDK_VERSION)
// versionCode = AndroidConfig.VERSION_CODE
// versionName = AndroidConfig.VERSION_NAME
//
// testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// }
//
//
// kotlinOptions {
// jvmTarget = "1.8"
// }
//
// signingConfigs {
// named("release").configure {
// keyAlias = keystoreProperties["keyAlias"].toString()
// keyPassword = keystoreProperties["keyPassword"].toString()
// storeFile = keystoreProperties["storeFile"]?.let { file(it) }
// storePassword = keystoreProperties["storePassword"].toString()
// }
// }
//
// buildTypes {
// getByName("release") {
// signingConfig = signingConfigs.getByName("release")
// buildConfigField("String", "BASE_URL", "${appProperties["releaseBaseUrl"]}")
// }
// getByName("debug") {
// buildConfigField("String", "BASE_URL", "${appProperties["debugBaseUrl"]}")
// isDebuggable = true
// }
// }
//
// flavorDimensions("version", "region")
// productFlavors {
// create("eu") {
// dimension = "region"
// resValue("string", "app_name", "X Project for EU")
// }
//
// create("usa") {
// dimension = "region"
// resValue("string", "app_name", "X Project for USA")
// }
//
// create("mena") {
// dimension = "region"
// resValue("string", "app_name", "X Project for Mena")
// }
//
// create("development") {
// dimension = "version"
// resConfigs("en", "xxhdpi")
// manifestPlaceholders =
// mapOf("deepLinkScheme" to "projectxdevscheme", "deepLinkHost" to "deep.project.x")
// }
// create("play") {
// dimension = "version"
// manifestPlaceholders =
// mapOf("deepLinkScheme" to "projectxdevscheme", "deepLinkHost" to "deep.project.x")
//
//
// }
// create("demo") {
// dimension = "version"
// resConfigs("en", "xxhdpi")
// manifestPlaceholders =
// mapOf("deepLinkScheme" to "projectxdevscheme", "deepLinkHost" to "deep.project.x")
// resValue("string", "app_name", "Demo Project x")
// }
// }
//
// testOptions {
// unitTests.isReturnDefaultValues = true
// unitTests.isIncludeAndroidResources = true
// }
//
//
//
//}
//
//