-
Notifications
You must be signed in to change notification settings - Fork 6
/
firebase-app.gradle
89 lines (79 loc) · 4.39 KB
/
firebase-app.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
// Configuration applied to our example app projects which need Firebase build configuration for:
// - Crashlytics
// - App Distribution
// These files are optional for builds of this project.
// Depending on the file, it needs to be placed either in this project's folder or at repository root
// (e.g. by our assemble GitHub workflow).
// These files should never be checked in, hence why they're also in this project's Git ignore file.
final firebaseAppDistributionPrivateKeyFile = project.rootProject.file('firebase-app-distribution-private-key.json')
final signingKeyStoreFile = project.rootProject.file('signing.jks')
final hasGoogleServices = project.file('google-services.json').exists()
final canDistribute = firebaseAppDistributionPrivateKeyFile.exists()
if (hasGoogleServices) {
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
logger.lifecycle("✅ Google Services and Crashlytics")
}
if (canDistribute) {
if (!hasGoogleServices) {
// When we configure `android.buildTypes.release.firebaseAppDistribution` then we don't want to have to supply
// values which can already be found in google-services.json (e.g. appId).
// Therefore, this project build insists on Google Services configuration being available if Firebase App
// Distribution (`canDistribute`) is in the mix.
throw new GradleException("Firebase App Distribution private key file was found but Google Services file was not found.")
}
apply plugin: 'com.google.firebase.appdistribution'
logger.lifecycle("✅ Firebase App Distribution")
}
// By design, these properties are only injected by our adhoc-publish-example-apps workflow, not by other workflows (for example, publish-example-apps).
// This means that when not adhoc-publishing example app builds they will all have a value of `null` (org.codehaus.groovy.runtime.NullObject).
final githubTitle = findProperty("ABLY_BUILD_CONTEXT_TITLE")
final includeIndividualRiders = findProperty("APP_DISTRIBUTION_INCLUDE_INDIVIDUAL_RIDERS")
final additionalReleaseNotes = findProperty("APP_DISTRIBUTION_RELEASE_NOTES")
logger.lifecycle("githubTitle [${githubTitle.getClass()}]: $githubTitle")
logger.lifecycle("includeIndividualRiders [${includeIndividualRiders.getClass()}]: $includeIndividualRiders")
logger.lifecycle("additionalReleaseNotes [${additionalReleaseNotes.getClass()}]: $additionalReleaseNotes")
android {
if (canDistribute) {
if (!(signingKeyStoreFile.exists())) {
throw new GradleException("Java KeyStore file was not found, despite the presence of a Firebase App Distribution private key file.")
}
signingConfigs {
release {
keyAlias findProperty("ANDROID_SIGNING_KEY_ALIAS")
keyPassword findProperty("ANDROID_SIGNING_KEY_PASSWORD")
storeFile signingKeyStoreFile
storePassword findProperty("ANDROID_SIGNING_STORE_PASSWORD")
}
}
}
buildTypes {
release {
if (canDistribute) {
// https://firebase.google.com/docs/app-distribution/android/distribute-gradle#step_3_configure_your_distribution_properties
firebaseAppDistribution {
serviceCredentialsFile = firebaseAppDistributionPrivateKeyFile.getAbsolutePath()
if (includeIndividualRiders == "true") {
groups = "individual-riders"
}
if (githubTitle || additionalReleaseNotes) {
releaseNotes = additionalReleaseNotes ? "$additionalReleaseNotes\n\n" : ""
releaseNotes += githubTitle ? githubTitle : ""
}
}
signingConfig signingConfigs.release
}
}
}
}
dependencies {
// Add application runtime implementation dependencies required for Crashlytics.
if (hasGoogleServices) {
// The BoM for the Firebase platform (it specifies the versions for Firebase dependencies).
implementation platform('com.google.firebase:firebase-bom:31.2.0')
// Firebase dependencies, which should not specifies versions as those are provided
// for us because we're including the BoM above.
// see: https://firebase.google.com/docs/crashlytics/get-started?platform=android
implementation 'com.google.firebase:firebase-crashlytics'
}
}