forked from firebase/firebase-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase_dependencies.gradle
153 lines (139 loc) · 4.99 KB
/
firebase_dependencies.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
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// A map of library to the dependencies that need to be added for it.
def firebaseDependenciesMap = [
'app' : ['com.google.firebase:firebase-analytics:16.5.0'],
'admob' : ['com.google.firebase:firebase-ads:17.2.0',
'com.google.android.gms:play-services-measurement-sdk-api:16.5.0'],
'analytics' : ['com.google.firebase:firebase-analytics:16.5.0'],
'auth' : ['com.google.firebase:firebase-auth:17.0.0'],
'database' : ['com.google.firebase:firebase-database:17.0.0'],
'dynamic_links' : ['com.google.firebase:firebase-invites:17.0.0'],
'functions' : ['com.google.firebase:firebase-functions:17.0.0'],
'instance_id' : ['com.google.firebase:firebase-iid:18.0.0'],
'invites' : ['com.google.firebase:firebase-invites:17.0.0'],
// Messaging has an additional local dependency to include.
'messaging' : ['com.google.firebase:firebase-messaging:18.0.0',
'firebase_cpp_sdk.messaging:messaging_java'],
'performance' : ['com.google.firebase:firebase-perf:17.0.0'],
'remote_config' : ['com.google.firebase:firebase-config:17.0.0'],
'storage' : ['com.google.firebase:firebase-storage:17.0.0']
]
// A map of library to the gradle resources that they depend upon.
def firebaseResourceDependenciesMap = [
'app' : [':app:app_resources',
':app:google_api_resources',
':app:invites_resources'],
'admob' : [':admob:admob_resources'],
'auth' : [':auth:auth_resources'],
'database' : [':database:database_resources'],
'storage' : [':storage:storage_resources']
]
def setResourceDependencies(String subproject) {
preDebugBuild.dependsOn gradle.includedBuild('firebase_cpp_sdk').task(
"$subproject:generateDexJarDebug")
preDebugBuild.dependsOn gradle.includedBuild('firebase_cpp_sdk').task(
"$subproject:generateDexJarRelease")
}
// Handles adding the Firebase C++ dependencies as properties.
class Dependencies {
HashSet<String> libSet = new HashSet<String>()
def getApp() {
libSet.add('app')
}
def getAdmob() {
libSet.add('admob')
}
def getAnalytics() {
libSet.add('analytics')
}
def getAuth() {
libSet.add('auth')
}
def getDatabase() {
libSet.add('database')
}
def getDynamicLinks() {
libSet.add('dynamic_links')
}
def getFunctions() {
libSet.add('functions')
}
def getInstanceId() {
libSet.add('instance_id')
}
def getInvites() {
libSet.add('invites')
}
def getMessaging() {
libSet.add('messaging')
}
def getPerformance() {
libSet.add('performance')
}
def getRemoteConfig() {
libSet.add('remote_config')
}
def getStorage() {
libSet.add('storage')
}
}
// Extension to handle which Firebase C++ dependencies are being added to the
// gradle project.
// They are added via: firebaseCpp.dependencies "admob", "analytics", ...
class FirebaseCppExtension {
Dependencies dependencies = new Dependencies()
void dependencies(Closure c) {
ConfigureUtil.configure(c, dependencies)
}
void dependencies(Action<? super Dependencies> action) {
action.execute(dependencies)
}
}
project.extensions.create('firebaseCpp', FirebaseCppExtension)
apply from: "${gradle.firebase_cpp_sdk_dir}/android_build_files/generate_proguard.gradle"
def generateAndAddProguard(String lib) {
// Set the property on the project, so it is easier to use
project.ext.firebase_cpp_sdk_dir = "${gradle.firebase_cpp_sdk_dir}"
// Generate the proguard file for the library, and add it to the project
generateProguardFileWithCallback(lib, new Action<File>() {
public void execute(File proguardFile) {
project.android.buildTypes.debug.proguardFile proguardFile
project.android.buildTypes.release.proguardFile proguardFile
}
})
}
project.afterEvaluate {
if (!firebaseCpp.dependencies.libSet.isEmpty()) {
// App is required, so add it if it wasn't included.
if (!firebaseCpp.dependencies.libSet.contains('app')) {
firebaseCpp.dependencies.libSet.add('app')
}
for (String lib : firebaseCpp.dependencies.libSet) {
// Generate and include the proguard file
generateAndAddProguard(lib)
// Add the dependencies for the library
for (String dep : firebaseDependenciesMap.get(lib)) {
project.dependencies {
implementation "$dep"
}
}
if (firebaseResourceDependenciesMap.containsKey(lib)) {
for (String resDep : firebaseResourceDependenciesMap.get(lib)) {
setResourceDependencies(resDep)
}
}
}
}
}