|
| 1 | +# firebase-dataconnect |
| 2 | + |
| 3 | +This is the Firebase Android Data Connect SDK. |
| 4 | + |
| 5 | +## Building |
| 6 | + |
| 7 | +All Gradle commands should be run from the source root (which is one level up |
| 8 | +from this folder). See the README.md in the source root for instructions on |
| 9 | +publishing/testing Firebase Data Connect. |
| 10 | + |
| 11 | +To build Firebase Data Connect, from the source root run: |
| 12 | +```bash |
| 13 | +./gradlew :firebase-dataconnect:assembleRelease |
| 14 | +``` |
| 15 | + |
| 16 | +## Unit Testing |
| 17 | + |
| 18 | +To run unit tests for Firebase Data Connect, from the source root run: |
| 19 | +```bash |
| 20 | +./gradlew :firebase-dataconnect:check |
| 21 | +``` |
| 22 | + |
| 23 | +## Integration Testing |
| 24 | + |
| 25 | +Running integration tests requires a Firebase project because they connect to |
| 26 | +the Firebase Data Connect backend. |
| 27 | + |
| 28 | +See [here](../README.md#project-setup) for how to setup a project. |
| 29 | + |
| 30 | +Once you setup the project, download `google-services.json` and place it in |
| 31 | +the source root. |
| 32 | + |
| 33 | +Make sure you have created a Firebase Data Connect instance for your project, |
| 34 | +before you proceed. |
| 35 | + |
| 36 | +By default, integration tests run against the Firebase Data Connect emulator. |
| 37 | + |
| 38 | +### Setting up the Firebase Data Connect Emulator |
| 39 | + |
| 40 | +The integration tests require that the Firebase Data Connect emulator is running |
| 41 | +on port 9399, which is default when running it via the Data Connect Toolkit. |
| 42 | + |
| 43 | + * [Install the Firebase CLI](https://firebase.google.com/docs/cli/). |
| 44 | + ``` |
| 45 | + npm install -g firebase-tools |
| 46 | + ``` |
| 47 | + * [Install the Firebase Data Connect |
| 48 | + emulator](https://firebase.google.com/docs/FIX_URL/security/test-rules-emulator#install_the_emulator). |
| 49 | + ``` |
| 50 | + firebase setup:emulators:dataconnect |
| 51 | + ``` |
| 52 | + * Run the emulator |
| 53 | + ``` |
| 54 | + firebase emulators:start --only dataconnect |
| 55 | + ``` |
| 56 | + * Select the `Firebase Data Connect Integration Tests (Firebase Data Connect |
| 57 | + Emulator)` run configuration to run all integration tests. |
| 58 | +
|
| 59 | +To run the integration tests against prod, select |
| 60 | +`DataConnectProdIntegrationTest` run configuration. |
| 61 | +
|
| 62 | +### Run on Local Android Emulator |
| 63 | +
|
| 64 | +Then run: |
| 65 | +```bash |
| 66 | +./gradlew :firebase-dataconnect:connectedCheck |
| 67 | +``` |
| 68 | + |
| 69 | +### Run on Firebase Test Lab |
| 70 | + |
| 71 | +You can also test on Firebase Test Lab, which allow you to run the integration |
| 72 | +tests on devices hosted in a Google data center. |
| 73 | + |
| 74 | +See [here](../README.md#running-integration-tests-on-firebase-test-lab) for |
| 75 | +instructions of how to setup Firebase Test Lab for your project. |
| 76 | + |
| 77 | +Run: |
| 78 | +```bash |
| 79 | +./gradlew :firebase-dataconnect:deviceCheck |
| 80 | +``` |
| 81 | + |
| 82 | +## Code Formatting |
| 83 | + |
| 84 | +Run below to format Kotlin and Java code: |
| 85 | +```bash |
| 86 | +./gradlew :firebase-dataconnect:spotlessApply |
| 87 | +``` |
| 88 | + |
| 89 | +See [here](../README.md#code-formatting) if you want to be able to format code |
| 90 | +from within Android Studio. |
| 91 | + |
| 92 | +## Build Local Jar of Firebase Data Connect SDK |
| 93 | + |
| 94 | +```bash |
| 95 | +./gradlew -PprojectsToPublish="firebase-dataconnect" publishReleasingLibrariesToMavenLocal |
| 96 | +``` |
| 97 | + |
| 98 | +Developers may then take a dependency on these locally published versions by adding |
| 99 | +the `mavenLocal()` repository to your [repositories |
| 100 | +block](https://docs.gradle.org/current/userguide/declaring_repositories.html) in |
| 101 | +your app module's build.gradle. |
| 102 | + |
| 103 | +## Misc |
| 104 | +After importing the project into Android Studio and building successfully |
| 105 | +for the first time, Android Studio will delete the run configuration xml files |
| 106 | +in `./idea/runConfigurations`. Undo these changes with the command: |
| 107 | + |
| 108 | +``` |
| 109 | +$ git checkout .idea/runConfigurations |
| 110 | +``` |
0 commit comments