@@ -124,136 +124,90 @@ Run below to format Java code:
124
124
See [ here] ( ../README.md#code-formatting ) if you want to be able to format code from within Android
125
125
Studio.
126
126
127
- ## Roll your own build of firebase-firestore for use in your application
127
+ ## Using a custom build in your application
128
128
129
- It is possible, and, indeed, quite easy, to compile the ` firebase-firestore ` Gradle artifact from
130
- source and then use that self-compiled artifact in your Android application .
129
+ To build ` firebase-firestore ` from source and use the resulting artifact in your
130
+ Android application, follow these steps .
131
131
132
- ### Update gradle.properties with a custom version number
132
+ ### 1. Set a custom version
133
133
134
- First, edit ` firebase-firestore/gradle.properties ` and change the "version" to something unique. It
135
- can be especially helpful to append a "-something" suffix to the version name, replacing "something"
136
- with some description of your change. Doing so will give you confidence that you are indeed using
137
- your self-compiled version in your application and not accidentally using an officially-published
138
- version.
139
-
140
- For example, you can change the contents of ` firebase-firestore/gradle.properties ` from
134
+ In ` firebase-firestore/gradle.properties ` , change the ` version ` to a unique
135
+ value. Appending a suffix makes it easy to identify your custom build.
141
136
137
+ For example, change:
142
138
```
143
139
version=26.0.2
144
140
latestReleasedVersion=26.0.1
145
141
```
146
142
147
- to
148
-
143
+ To:
149
144
```
150
145
version=99.99.99-MyFix1
151
146
latestReleasedVersion=26.0.1
152
147
```
153
148
154
- ### Build the ` firebase-firestore ` Gradle artifact
155
-
156
- Then, build the ` firebase-firestore ` Gradle artifact by running:
149
+ ### 2. Build the artifact
157
150
151
+ Build and publish the artifact to your local Maven repository:
158
152
``` bash
159
153
./gradlew :firebase-firestore:publishToMavenLocal
160
154
```
161
155
162
- ### Add mavenLocal() repository to your Android app
163
-
164
- In order to take a dependency on the self-compiled ` firebase-firestore ` Gradle artifact, first add
165
- ` mavenLocal() ` to the
166
- [ ` dependencyResolutionManagement.repositories ` ] ( https://docs.gradle.org/current/userguide/declaring_repositories.html )
167
- section of your Android application's ` settings.gradle ` or ` settings.gradle.kts ` file.
156
+ ### 3. Update your app's repositories
168
157
169
- For example, you would change something like
158
+ In your application's ` settings.gradle ` or ` settings.gradle.kts ` file, add
159
+ ` mavenLocal() ` to the ` repositories ` block within
160
+ ` dependencyResolutionManagement ` .
170
161
171
162
``` kotlin
172
163
dependencyResolutionManagement {
173
164
repositoriesMode.set(RepositoriesMode .FAIL_ON_PROJECT_REPOS )
174
165
repositories {
175
166
google()
176
167
mavenCentral()
168
+ mavenLocal() // Add this line
177
169
}
178
170
}
179
171
```
180
172
181
- to
182
-
183
- ``` kotlin
184
- dependencyResolutionManagement {
185
- repositoriesMode.set(RepositoriesMode .FAIL_ON_PROJECT_REPOS )
186
- repositories {
187
- google()
188
- mavenCentral()
189
- mavenLocal() // Add this line to use artifacts published by `publishToMavenLocal`
190
- }
191
- }
192
- ```
173
+ ### 4. Update your app's dependencies
193
174
194
- ### Change the firebase-firestore dependency in your Android app
195
-
196
- Then, edit your Android application's ` build.gradle ` or ` build.gradle.kts ` to use the self-compiled
197
- Gradle ` firebase-firestore ` artifact.
198
-
199
- For example, you would change something like
175
+ In your application's ` build.gradle ` or ` build.gradle.kts ` file, update the
176
+ ` firebase-firestore ` dependency to use the custom version you set in step 1.
200
177
201
178
``` kotlin
202
179
dependencies {
203
180
implementation(platform(" com.google.firebase:firebase-bom:34.3.0" ))
204
- implementation(" com.google.firebase:firebase-firestore" )
205
- // ... the rest of your application's dependencies
206
- }
207
- ```
208
-
209
- to
210
-
211
- ``` kotlin
212
- dependencies {
213
- implementation(platform(" com.google.firebase:firebase-bom:34.3.0" ))
214
- // Use the custom version you set in gradle.properties in the next line.
181
+ // Use the custom version from gradle.properties
215
182
implementation(" com.google.firebase:firebase-firestore:99.99.99-MyFix1" )
216
- // ... the rest of your application's dependencies
183
+ // ... other dependencies
217
184
}
218
185
```
219
186
220
- ### (Optional) Log the firebase-firestore version to logcat
221
-
222
- It can be helpful to see in the logs which exact version of the ` firebase-firestore ` Gradle artifact
223
- your application is using. This increases the confidence that your application is indeed using the
224
- custom, self-compiled artifact rather than an official artifact.
187
+ ### Optional: Verify the version at runtime
225
188
226
- To do this, simply add a line like the following somewhere in your Android application:
189
+ To confirm that your application is using the custom artifact, you can log its
190
+ version. Add the following code to your application:
227
191
228
192
``` kotlin
229
193
android.util.Log .i(" FirestoreVersion" , com.google.firebase.firestore.BuildConfig .VERSION_NAME )
230
194
```
231
195
232
- ### (Rarely required) Self-compile dependencies of firebase-firestore
233
-
234
- The ` firebase-firestore ` Gradle artifact includes dependencies on a few peer modules in the
235
- ` firebase-android-sdk ` repository. Although rare, sometimes you want, or need, to include local
236
- changes to these dependencies in your self-compiled build.
237
-
238
- At the time of writing, the peer dependencies of ` firebase-firestore ` include:
239
-
240
- - ` firebase-common `
241
- - ` firebase-components `
242
- - ` firebase-database-collection `
243
- - ` protolite-well-known-types `
196
+ ### Building with local module dependencies
244
197
245
- For purposes of example, suppose there is a local change to ` firebase-common ` that you want your
246
- self-compiled ` firebase-firestore ` artifact to pick up. Follow the steps below to do this, adapting
247
- the steps as appropriate if your specific case uses a _ different_ dependency.
198
+ If your changes require building other modules in this repository (like
199
+ ` firebase-common ` ), you must build and publish them locally as well.
248
200
249
- 1 . Edit ` firebase-common/gradle.properties ` , changing the verson to something like ` 99.99.99 ` .
250
- 2 . Compile and publish the ` firebase-common ` Gradle artifact by running:
251
- ` ./gradlew :firebase-common:publishToMavenLocal `
252
- 3 . If necessary, edit ` firebase-firestore/firebase-firestore.gradle ` to use a _ project_ dependency
253
- on the artifact. For example, change ` api(libs.firebase.common) ` to
254
- ` api(project(":firebase-common")) `
255
- 4 . Compile and publish the ` firebase-firestore ` Gradle artifact as documented above, namely, by
256
- running ` ./gradlew :firebase-firestore:publishToMavenLocal `
201
+ 1 . In the dependency's directory (e.g., ` firebase-common/ ` ), edit
202
+ ` gradle.properties ` to set a unique version.
203
+ 2 . Publish the dependency to Maven Local:
204
+ ``` bash
205
+ ./gradlew :firebase-common:publishToMavenLocal
206
+ ```
207
+ 3. In ` firebase-firestore/firebase-firestore.gradle` , ensure the dependency is a
208
+ project dependency. For example, change ` api(libs.firebase.common)` to
209
+ ` api(project(" :firebase-common" ))` .
210
+ 4. Build and publish the ` firebase-firestore` artifact as described in step 2.
257
211
258
212
# # Misc
259
213
0 commit comments