-
Notifications
You must be signed in to change notification settings - Fork 133
/
build.gradle
490 lines (422 loc) · 19 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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
import se.bjurr.violations.comments.github.plugin.gradle.ViolationCommentsToGitHubTask
import se.bjurr.violations.lib.model.SEVERITY
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
id 'org.jetbrains.kotlin.plugin.parcelize'
id 'dagger.hilt.android.plugin'
id 'se.bjurr.violations.violation-comments-to-github-gradle-plugin'
id 'io.sentry.android.gradle'
id 'androidx.navigation.safeargs.kotlin'
id 'com.google.gms.google-services'
}
repositories {
maven {
url 'https://a8c-libs.s3.amazonaws.com/android'
content {
includeGroup "org.wordpress"
includeGroup "org.wordpress.fluxc"
includeGroup "org.wordpress.fluxc.plugins"
includeGroup "org.wordpress.wellsql"
includeGroup "org.wordpress.mediapicker"
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
}
}
maven {
url 'https://zendesk.jfrog.io/zendesk/repo'
content {
includeGroup "com.zendesk"
includeGroup "com.zendesk.belvedere2"
}
}
mavenCentral()
maven {
url "https://a8c-libs.s3.amazonaws.com/android/jcenter-mirror"
content {
includeVersion "com.android.volley", "volley", "1.1.1"
includeVersion "com.google.android", "flexbox", "2.0.1"
includeVersion "com.jraska", "falcon", "2.1.1"
includeVersion "org.wordpress", "wellsql", "1.6.0"
includeVersion "org.wordpress", "wellsql-core", "1.6.0"
}
}
maven {
url "https://jitpack.io"
content {
includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "aztec")
includeModule("com.github.wordpress-mobile.WordPress-Aztec-Android", "glide-loader")
includeModule("com.github.chrisbanes", "PhotoView")
includeModule("com.github.PhilJay", "MPAndroidChart")
}
}
}
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.woocommerce.android"
// Allow versionName to be overridden with property. e.g. -PversionName=1234
if (project.hasProperty("versionName")) {
versionName project.property("versionName")
} else {
versionName "9.5-rc-1"
}
versionCode 310
minSdkVersion 21
// Update targetSdkVersion only after reviewing all the OS changes (developer.android.com/about/versions/[ENTER_ANDROID_VERSION]/migration)
// and thoroughly testing the app. Consider publishing a p2 post to inform the team about the upcoming change.
// P.S. Update the targetSdkVersion in all the modules, otherwise static analysis tools won't give you a heads-up about potential issues.
targetSdkVersion 31
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner 'com.woocommerce.android.WooCommerceTestRunner'
// TODO remove this once the hilt migration is complete
javaCompileOptions.annotationProcessorOptions.arguments['dagger.hilt.disableModulesHaveInstallInCheck'] = 'true'
buildConfigField "boolean", "USE_SIMULATED_READER", project.hasProperty("useSimulatedReader").toString()
packagingOptions {
exclude 'META-INF/gradle/incremental.annotation.processors'
exclude("META-INF/*.kotlin_module")
pickFirst 'META-INF/AL2.0'
pickFirst 'META-INF/LGPL2.1'
}
}
buildFeatures {
compose true
viewBinding true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += [
"-Xopt-in=kotlin.RequiresOptIn"
]
}
composeOptions {
kotlinCompilerExtensionVersion composeVersion
}
flavorDimensions "buildType"
productFlavors {
// Used for release/beta builds. Usually shouldn't be build locally.
// AppName: WooCommerce
vanilla {
dimension "buildType"
}
// Used for local development - preferred variant for developers.
// AppName: WooCommerce (Dev)
wasabi {
applicationId "com.woocommerce.android.dev"
dimension "buildType"
isDefault true
}
// Used for CI builds on PRs (downloadable apks). Can be used locally when a developer needs
// to install multiple versions of the app on the same device.
// AppName: WooCommerce (PreAlpha)
jalapeno {
applicationId "com.woocommerce.android.prealpha"
dimension "buildType"
}
}
buildTypes {
release {
// Proguard is used to shrink our apk, and reduce the number of methods in our final apk,
// but we don't obfuscate the bytecode.
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
pseudoLocalesEnabled true
isDefault true
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
release.java.srcDirs += 'src/release/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
lintOptions {
disable 'InvalidPackage'
// TODO remove this after we update AGP, it's a bug that has been fixed in 4.1.1 and later
// see: https://issuetracker.google.com/issues/168794947
disable "ParcelCreator"
}
testOptions {
animationsDisabled = true
}
}
dependencies {
implementation("org.wordpress:libaddressinput.common:$libaddressinputVersion") {
exclude group: "org.json", module: "json"
exclude group: "com.google.guava", module: "guava"
}
implementation 'com.google.firebase:firebase-messaging-ktx:23.0.5'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
// Support library
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.core:core-ktx:$coreKtxVersion"
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "androidx.cardview:cardview:1.0.0"
implementation("androidx.browser:browser:1.4.0") {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
implementation "androidx.preference:preference:1.2.0"
implementation "androidx.datastore:datastore-preferences:1.0.0"
implementation "androidx.navigation:navigation-fragment-ktx:$gradle.ext.navigationVersion"
implementation "androidx.navigation:navigation-ui-ktx:$gradle.ext.navigationVersion"
implementation("org.wordpress:utils:$wordPressUtilsVersion") {
exclude group: "com.mcxiaoke.volley"
exclude group: "com.android.support"
}
implementation 'com.automattic:Automattic-Tracks-Android:2.2.0'
implementation("${gradle.ext.fluxCBinaryPath}:$fluxCVersion") {
exclude group: "com.android.support"
exclude group: "org.wordpress", module: "utils"
}
implementation("${gradle.ext.fluxCWooCommercePluginBinaryPath}:$fluxCVersion") {
exclude group: "com.android.support"
exclude group: "org.wordpress", module: "utils"
}
implementation("$gradle.ext.loginFlowBinaryPath:$wordPressLoginVersion") {
exclude group: "org.wordpress", module: "utils"
exclude group: "org.wordpress", module: "fluxc"
}
implementation("com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:$aztecVersion") {
exclude group: "com.android.volley"
exclude group: "com.android.support"
exclude group: "org.wordpress", module: "utils"
}
implementation("com.github.wordpress-mobile.WordPress-Aztec-Android:glide-loader:$aztecVersion") {
exclude group: "com.android.volley"
exclude group: "com.android.support"
exclude group: "org.wordpress", module: "utils"
}
implementation project(":libs:cardreader")
implementation 'com.facebook.shimmer:shimmer:0.5.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation "com.automattic:about:$aboutAutomatticVersion"
// Dagger
implementation "com.google.dagger:hilt-android:$gradle.ext.daggerVersion"
implementation "androidx.hilt:hilt-navigation-fragment:$hiltJetpackVersion"
kapt "com.google.dagger:hilt-compiler:$gradle.ext.daggerVersion"
implementation "com.google.dagger:dagger-android-support:$gradle.ext.daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$gradle.ext.daggerVersion"
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation "com.github.bumptech.glide:glide:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
implementation "com.github.bumptech.glide:volley-integration:$glideVersion@aar"
implementation "org.greenrobot:eventbus:$eventBusVersion"
implementation "com.google.android.play:core:$googlePlayCoreVersion"
// Debug dependencies
debugImplementation "com.facebook.flipper:flipper:$flipperVersion"
debugImplementation "com.facebook.soloader:soloader:0.10.3"
debugImplementation("com.facebook.flipper:flipper-network-plugin:$flipperVersion") {
// Force Flipper to use the okhttp version defined in the fluxc module
// okhttp versions higher than 3.9.0 break handling for self-signed SSL sites
// See https://github.com/wordpress-mobile/WordPress-FluxC-Android/issues/919
exclude group: 'com.squareup.okhttp3'
}
debugImplementation 'com.squareup.leakcanary:leakcanary-android-core:2.9.1'
// Dependencies for local unit tests
testImplementation "junit:junit:$jUnitVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.mockito:mockito-inline:$mockitoVersion"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$gradle.ext.kotlinVersion"
testImplementation "org.assertj:assertj-core:$assertjVersion"
testImplementation("androidx.arch.core:core-testing:2.1.0", {
exclude group: 'com.android.support', module: 'support-compat'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-core-utils'
})
// Dependencies for Espresso UI tests
androidTestImplementation "androidx.test.ext:junit:$jUnitExtVersion"
androidTestImplementation "androidx.test:rules:$androidxTestCoreVersion"
androidTestImplementation "org.assertj:assertj-core:$assertjVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
androidTestImplementation "com.google.dagger:hilt-android-testing:$gradle.ext.daggerVersion"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$gradle.ext.daggerVersion"
// Dependencies for screenshots
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
androidTestImplementation('com.github.tomakehurst:wiremock:2.26.3') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.apache.commons', module: 'commons-lang3'
exclude group: 'asm', module: 'asm'
exclude group: 'org.json', module: 'json'
}
androidTestImplementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
// Resolve conflicts between main and test APK
androidTestImplementation "androidx.annotation:annotation:1.3.0"
implementation ("com.zendesk:support:5.0.8") {
exclude group: 'com.android.support', module: 'support-annotations'
}
// ViewModel and LiveData
implementation "androidx.fragment:fragment-ktx:1.4.1"
implementation "androidx.activity:activity-ktx:1.4.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-process:$lifecycleVersion"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
testImplementation 'app.cash.turbine:turbine:0.8.0'
// Use caution when updating this, as commons-text 1.9 caused the reviews tab to crash on API 21
implementation "org.apache.commons:commons-text:1.8"
implementation "commons-io:commons-io:2.11.0"
implementation "com.tinder.statemachine:statemachine:$stateMachineVersion"
implementation("${gradle.ext.mediaPickerBinaryPath}:$mediapickerVersion") {
exclude group: "org.wordpress", module: "utils"
}
implementation("${gradle.ext.mediaPickerSourceDeviceBinaryPath}:$mediapickerVersion")
implementation("${gradle.ext.mediaPickerSourceWordPressBinaryPath}:$mediapickerVersion") {
exclude group: "org.wordpress", module: "utils"
exclude group: "org.wordpress", module: "fluxc"
}
// Jetpack Compose
implementation 'androidx.activity:activity-compose:1.4.0'
implementation "com.google.accompanist:accompanist-swiperefresh:$composeAccompanistVersion"
implementation "androidx.compose.material:material:$composeVersion"
implementation "androidx.compose.animation:animation:$composeVersion"
implementation "androidx.compose.ui:ui-tooling:$composeVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleViewmodelComposeVersion"
implementation "androidx.compose.runtime:runtime-livedata:$composeVersion"
implementation "com.google.android.material:compose-theme-adapter:$composeThemeAdapterVersion"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$composeVersion"
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion"
implementation "io.coil-kt:coil-compose:$coilVersion"
}
task copyGoogleServicesExampleFile(type: Copy) {
from('.')
into('.')
include('google-services.json-example')
rename('google-services.json-example', 'google-services.json')
}
// Add properties named "wc.xxx" to our BuildConfig
android.buildTypes.all { buildType ->
def inputFile = checkGradlePropertiesFile()
def properties = loadPropertiesFromFile(inputFile)
properties.any { property ->
if (property.key.toLowerCase().startsWith("wc.")) {
buildType.buildConfigField "String", property.key.replace("wc.", "").replace(".", "_").toUpperCase(),
"\"${property.value}\""
}
if (property.key.toLowerCase().startsWith("wc.res.")) {
buildType.resValue "string", property.key.replace("wc.res.", "").replace(".", "_").toLowerCase(),
"${property.value}"
}
}
// If Google services file doesn't exist, copy example file.
if (!file("google-services.json").exists()) {
tasks.copyGoogleServicesExampleFile.copy()
}
// Print warning message if example Google services file is used.
if ((file("google-services.json").text) == (file("google-services.json-example").text)) {
println("WARNING: You're using the example google-services.json file. Google login will fail.")
}
}
tasks.register("violationCommentsToGitHub", ViolationCommentsToGitHubTask) {
repositoryOwner = "woocommerce"
repositoryName = "woocommerce-android"
pullRequestId = System.properties['GITHUB_PULLREQUESTID']
username = System.properties['GITHUB_USERNAME']
password = System.properties['GITHUB_PASSWORD']
oAuth2Token = System.properties['GITHUB_OAUTH2TOKEN']
gitHubUrl = "https://api.github.com/"
createCommentWithAllSingleFileComments = false
createSingleFileComments = true
commentOnlyChangedContent = true
minSeverity = SEVERITY.INFO //ERROR, INFO, WARN
commentTemplate = """
**Reporter**: {{violation.reporter}}{{#violation.rule}}\n
**Rule**: {{violation.rule}}{{/violation.rule}}
**Severity**: {{violation.severity}}
**File**: {{violation.file}}:{{violation.startLine}}{{#violation.source}}
**Source**: {{violation.source}}{{/violation.source}}
{{violation.message}}
"""
violations = [
["CHECKSTYLE", ".", ".*/build/.*/checkstyle/.*\\.xml\$", "CheckStyle"],
["CHECKSTYLE", ".", ".*/build/.*/detekt/.*\\.xml\$", "Detekt"]
]
}
tasks.register("dependencyTreeDiffCommentToGitHub", ViolationCommentsToGitHubTask) {
repositoryOwner = "woocommerce"
repositoryName = "woocommerce-android"
pullRequestId = System.properties['GITHUB_PULLREQUESTID']
oAuth2Token = System.properties['GITHUB_OAUTH2TOKEN']
gitHubUrl = "https://api.github.com/"
createCommentWithAllSingleFileComments = true
createSingleFileComments = false
commentOnlyChangedContent = true
commentOnlyChangedFiles = false
minSeverity = SEVERITY.INFO
commentTemplate = """
### The PR caused the following dependency changes:
<details><summary>expand</summary>
<p>
```diff
{{{violation.message}}}
```
</p>
</details>
*Please review and act accordingly*
"""
violations = [
["GENERIC", ".", ".*/build/.*/diff/.*\\.txt\$", "DependenciesDiffChecker"],
]
}
task printVersionName {
doLast {
println android.defaultConfig.versionName
}
}
def checkGradlePropertiesFile() {
def inputFile = file("${rootDir}/gradle.properties")
if (!inputFile.exists()) {
throw new StopActionException("Build configuration file gradle.properties doesn't exist, follow README instructions")
}
return inputFile
}
static def loadPropertiesFromFile(inputFile) {
def properties = new Properties()
inputFile.withInputStream { stream ->
properties.load(stream)
}
return properties
}
// For app signing
if (["uploadStoreFile", "uploadStorePassword", "uploadKeyAlias", "uploadKeyPassword"].count { !project.hasProperty(it) } == 0) {
android {
signingConfigs {
release {
storeFile = rootProject.file(project.uploadStoreFile)
storePassword = project.uploadStorePassword
keyAlias = project.uploadKeyAlias
keyPassword = project.uploadKeyPassword
}
}
}
android.buildTypes.release.signingConfig = android.signingConfigs.release
}
if (project.hasProperty("debugStoreFile")) {
def sharedDebugStore = file(project.debugStoreFile.replaceFirst("^~", System.getProperty("user.home")))
if (sharedDebugStore.exists()) {
android {
signingConfigs {
debug {
storeFile sharedDebugStore
}
}
}
}
}