Skip to content

Commit 89bc187

Browse files
committed
Merge branch 'ImplementDocumentIdAnnotation' of github.com:firebase/firebase-android-sdk into ImplementDocumentIdAnnotation
2 parents 3e6295b + ee7ec63 commit 89bc187

File tree

59 files changed

+3097
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3097
-71
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/license/LicenseResolverPlugin.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.BSDLicens
2323
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.CreativeCommonsLicenseFetcher
2424
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.GnuClasspathLicenseFetcher
2525
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.MITLicenseFetcher
26+
import com.google.firebase.gradle.plugins.license.RemoteLicenseFetcher.YetAnotherApache2LicenseFetcher
2627
import org.gradle.api.Plugin
2728
import org.gradle.api.Project
2829
import org.gradle.api.artifacts.Configuration
@@ -50,8 +51,9 @@ class LicenseResolverPlugin implements Plugin<Project> {
5051
List<RemoteLicenseFetcher> remoteLicenseFetchers =
5152
[new AndroidSdkTermsFetcher(),
5253
new Apache2LicenseFetcher(),
53-
new BSDLicenseFetcher(),
5454
new AnotherApache2LicenseFetcher(),
55+
new YetAnotherApache2LicenseFetcher(),
56+
new BSDLicenseFetcher(),
5557
new CreativeCommonsLicenseFetcher(), new MITLicenseFetcher(), new AnotherMITLicenseFetcher(), new GnuClasspathLicenseFetcher()]
5658
final static ANDROID_PLUGINS = ["com.android.application", "com.android.library",
5759
"com.android.test"]

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/license/RemoteLicenseFetcher.groovy

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,24 @@ interface RemoteLicenseFetcher extends Serializable {
5656
}
5757
}
5858

59-
static final class BSDLicenseFetcher implements RemoteLicenseFetcher {
60-
private URI BSD_LICENSE_URI = URI.create("http://www.opensource.org/licenses/bsd-license.php")
59+
static final class AnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
60+
private URI APACHE_2_LICENSE_URI = URI.create("https://opensource.org/licenses/Apache-2.0")
6161

6262
@Override
6363
URI getServiceUri() {
64-
BSD_LICENSE_URI
64+
APACHE_2_LICENSE_URI
6565
}
6666

6767
@Override
6868
String get() {
69-
def doc = Jsoup.connect(BSD_LICENSE_URI.toString()).get()
69+
def doc = Jsoup.connect(APACHE_2_LICENSE_URI.toString()).get()
7070

71-
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper')[0])
71+
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper'))
7272
}
7373
}
7474

75-
static final class AnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
76-
private URI APACHE_2_LICENSE_URI = URI.create("https://opensource.org/licenses/Apache-2.0")
75+
static final class YetAnotherApache2LicenseFetcher implements RemoteLicenseFetcher {
76+
private URI APACHE_2_LICENSE_URI = URI.create("http://www.apache.org/licenses/LICENSE-2.0")
7777

7878
@Override
7979
URI getServiceUri() {
@@ -82,9 +82,23 @@ interface RemoteLicenseFetcher extends Serializable {
8282

8383
@Override
8484
String get() {
85-
def doc = Jsoup.connect(APACHE_2_LICENSE_URI.toString()).get()
85+
APACHE_2_LICENSE_URI.toURL().getText()
86+
}
87+
}
8688

87-
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper'))
89+
static final class BSDLicenseFetcher implements RemoteLicenseFetcher {
90+
private URI BSD_LICENSE_URI = URI.create("http://www.opensource.org/licenses/bsd-license.php")
91+
92+
@Override
93+
URI getServiceUri() {
94+
BSD_LICENSE_URI
95+
}
96+
97+
@Override
98+
String get() {
99+
def doc = Jsoup.connect(BSD_LICENSE_URI.toString()).get()
100+
101+
TEXT_FORMATTER.getPlainText(doc.select('#content-wrapper')[0])
88102
}
89103
}
90104

@@ -151,4 +165,4 @@ interface RemoteLicenseFetcher extends Serializable {
151165
TEXT_FORMATTER.getPlainText(doc.select('body > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(3) > td > en > blockquote'))
152166
}
153167
}
154-
}
168+
}

firebase-common/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=17.0.0
2-
latestReleasedVersion=16.1.0
1+
version=17.1.1
2+
latestReleasedVersion=17.1.0
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
version=16.0.0
1+
version=16.0.1
2+
latestReleasedVersion=16.0.0
23
android.enableUnitTestBinaryResources=true

firebase-firestore/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Unreleased
2+
- [fixed] Updated gRPC to 1.21.0. A bug in the prior version would occasionally
3+
cause a crash if a network state change occurred concurrently with an RPC.
4+
(#428)
5+
6+
# 19.0.1
27
- [fixed] Fixed an issue that prevented schema migrations for clients with
38
large offline datasets (#370).
49

firebase-firestore/README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,84 @@ responsive apps that work regardless of network latency or Internet
1010
connectivity. Cloud Firestore also offers seamless integration with other
1111
Firebase and Google Cloud Platform products, including Cloud Functions.
1212

13+
## Building
14+
1315
All Gradle commands should be run from the source root (which is one level up
1416
from this folder). See the README.md in the source root for instructions on
1517
publishing/testing Cloud Firestore.
1618

17-
## Testing
19+
To build Cloud Firestore, from the source root run:
20+
```bash
21+
./gradlew :firebase-firestore:assembleRelease
22+
```
23+
24+
## Unit Testing
25+
26+
To run unit tests for Cloud Firestore, from the source root run:
27+
```bash
28+
./gradlew :firebase-firestore:check
29+
```
30+
31+
## Integration Testing
32+
33+
Running integration tests requires a Firebase project because they would try
34+
to connect to the Firestore backends.
35+
36+
See [here](../README.md#project-setup) for how to setup a project.
37+
38+
Once you setup the project, download `google-services.json` and place it in
39+
the source root.
40+
41+
Make sure you have created a Firestore instance for your project, before
42+
you proceed.
43+
44+
### Run on Local Emulator
45+
46+
Then simply run:
47+
```bash
48+
./gradlew :firebase-firestore:connectedCheck
49+
```
50+
51+
### Run on Firebase Test Lab
52+
53+
You can also test on Firebase Test Lab, which allow you to run the integration
54+
tests on devices hosted in Google data center.
55+
56+
See [here](../README.md#running-integration-tests-on-firebase-test-lab) for
57+
instructions of how to setup Firebase Test Lab for your project.
58+
59+
Run:
60+
```bash
61+
./gradlew :firebase-firestore:deviceCheck
62+
```
63+
64+
## Code Formatting
65+
66+
Run below to format Java code:
67+
```bash
68+
./gradlew :firebase-firestore:googleJavaFormat
69+
```
70+
71+
See [here](../README.md#code-formatting) if you want to be able to format code
72+
from within Android Studio.
73+
74+
## Build Local Jar of Firestore SDK
75+
76+
Run:
77+
```bash
78+
./gradlew publishAllToLocal
79+
```
80+
81+
This will publish firebase SDK at SNAPSHOT versions. All pom level dependencies
82+
within the published artifacts will also point to SNAPSHOT versions that are
83+
co-published. The results will be built into your local maven repo.
84+
85+
Developers may then take a dependency on these locally published versions by adding
86+
the `mavenLocal()` repository to your [repositories
87+
block](https://docs.gradle.org/current/userguide/declaring_repositories.html) in
88+
your app module's build.gradle.
1889

90+
## Misc
1991
After importing the project into Android Studio and building successfully
2092
for the first time, Android Studio will delete the run configuration xml files
2193
in `./idea/runConfigurations`. Undo these changes with the command:

firebase-firestore/firebase-firestore.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protobuf {
3030
}
3131
plugins {
3232
grpc {
33-
artifact = 'io.grpc:protoc-gen-grpc-java:1.16.1'
33+
artifact = 'io.grpc:protoc-gen-grpc-java:1.21.0'
3434
}
3535
javalite {
3636
// The codegen for lite comes as a separate artifact
@@ -102,10 +102,10 @@ dependencies {
102102
//To provide @Generated annotations
103103
compileOnly 'javax.annotation:jsr250-api:1.0'
104104

105-
implementation 'io.grpc:grpc-stub:1.16.1'
106-
implementation 'io.grpc:grpc-protobuf-lite:1.16.1'
107-
implementation 'io.grpc:grpc-okhttp:1.16.1'
108-
implementation 'io.grpc:grpc-android:1.16.1'
105+
implementation 'io.grpc:grpc-stub:1.21.0'
106+
implementation 'io.grpc:grpc-protobuf-lite:1.21.0'
107+
implementation 'io.grpc:grpc-okhttp:1.21.0'
108+
implementation 'io.grpc:grpc-android:1.21.0'
109109
implementation "com.google.android.gms:play-services-basement:$playServicesVersion"
110110
implementation "com.google.android.gms:play-services-tasks:$playServicesVersion"
111111
implementation "com.google.android.gms:play-services-base:$playServicesVersion"

firebase-firestore/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=19.0.1
2-
latestReleasedVersion=19.0.0
1+
version=19.0.2
2+
latestReleasedVersion=19.0.1

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/AbstractStream.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import com.google.firebase.firestore.util.AsyncQueue.DelayedTask;
2424
import com.google.firebase.firestore.util.AsyncQueue.TimerId;
2525
import com.google.firebase.firestore.util.ExponentialBackoff;
26-
import com.google.firebase.firestore.util.FirestoreChannel;
27-
import com.google.firebase.firestore.util.IncomingStreamObserver;
2826
import com.google.firebase.firestore.util.Logger;
2927
import io.grpc.ClientCall;
3028
import io.grpc.Metadata;

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/Datastore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.google.firebase.firestore.model.mutation.Mutation;
2727
import com.google.firebase.firestore.model.mutation.MutationResult;
2828
import com.google.firebase.firestore.util.AsyncQueue;
29-
import com.google.firebase.firestore.util.FirestoreChannel;
3029
import com.google.firebase.firestore.util.Supplier;
3130
import com.google.firestore.v1.BatchGetDocumentsRequest;
3231
import com.google.firestore.v1.BatchGetDocumentsResponse;
@@ -61,7 +60,7 @@
6160
public class Datastore {
6261

6362
/** Set of lowercase, white-listed headers for logging purposes. */
64-
public static final Set<String> WHITE_LISTED_HEADERS =
63+
static final Set<String> WHITE_LISTED_HEADERS =
6564
new HashSet<>(
6665
Arrays.asList(
6766
"date",

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/FirestoreCallCredentials.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.concurrent.Executor;
2525

2626
/** CallCredentials that applies any authorization headers. */
27-
public final class FirestoreCallCredentials extends CallCredentials2 {
27+
final class FirestoreCallCredentials extends CallCredentials2 {
2828

2929
private static final String LOG_TAG = "FirestoreCallCredentials";
3030

@@ -33,7 +33,7 @@ public final class FirestoreCallCredentials extends CallCredentials2 {
3333

3434
private final CredentialsProvider credentialsProvider;
3535

36-
public FirestoreCallCredentials(CredentialsProvider provider) {
36+
FirestoreCallCredentials(CredentialsProvider provider) {
3737
credentialsProvider = provider;
3838
}
3939

firebase-firestore/src/main/java/com/google/firebase/firestore/util/FirestoreChannel.java renamed to firebase-firestore/src/main/java/com/google/firebase/firestore/remote/FirestoreChannel.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.firestore.util;
15+
package com.google.firebase.firestore.remote;
1616

1717
import com.google.android.gms.tasks.Task;
1818
import com.google.android.gms.tasks.TaskCompletionSource;
@@ -21,7 +21,9 @@
2121
import com.google.firebase.firestore.FirebaseFirestoreException.Code;
2222
import com.google.firebase.firestore.auth.CredentialsProvider;
2323
import com.google.firebase.firestore.model.DatabaseId;
24-
import com.google.firebase.firestore.remote.FirestoreCallCredentials;
24+
import com.google.firebase.firestore.util.AsyncQueue;
25+
import com.google.firebase.firestore.util.Logger;
26+
import com.google.firebase.firestore.util.Util;
2527
import com.google.firestore.v1.FirestoreGrpc;
2628
import com.google.firestore.v1.FirestoreGrpc.FirestoreStub;
2729
import io.grpc.CallOptions;
@@ -38,7 +40,7 @@
3840
* Wrapper class around io.grpc.Channel that adds headers, exception handling and simplifies
3941
* invoking RPCs.
4042
*/
41-
public class FirestoreChannel {
43+
class FirestoreChannel {
4244

4345
private static final Metadata.Key<String> X_GOOG_API_CLIENT_HEADER =
4446
Metadata.Key.of("x-goog-api-client", Metadata.ASCII_STRING_MARSHALLER);
@@ -66,7 +68,7 @@ public class FirestoreChannel {
6668
/** The value to use as resource prefix header. */
6769
private final String resourcePrefixValue;
6870

69-
public FirestoreChannel(
71+
FirestoreChannel(
7072
AsyncQueue asyncQueue,
7173
CredentialsProvider credentialsProvider,
7274
ManagedChannel grpcChannel,

firebase-firestore/src/main/java/com/google/firebase/firestore/util/IncomingStreamObserver.java renamed to firebase-firestore/src/main/java/com/google/firebase/firestore/remote/IncomingStreamObserver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package com.google.firebase.firestore.util;
15+
package com.google.firebase.firestore.remote;
1616

1717
import io.grpc.Metadata;
1818
import io.grpc.Status;
1919

2020
/** Interface used for incoming/receiving gRPC streams. */
21-
public interface IncomingStreamObserver<RespT> {
21+
interface IncomingStreamObserver<RespT> {
2222
/** Headers were received for this stream. */
2323
void onHeaders(Metadata headers);
2424

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/WatchStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.firebase.firestore.model.SnapshotVersion;
2121
import com.google.firebase.firestore.util.AsyncQueue;
2222
import com.google.firebase.firestore.util.AsyncQueue.TimerId;
23-
import com.google.firebase.firestore.util.FirestoreChannel;
2423
import com.google.firestore.v1.FirestoreGrpc;
2524
import com.google.firestore.v1.ListenRequest;
2625
import com.google.firestore.v1.ListenResponse;

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/WriteStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import com.google.firebase.firestore.model.mutation.MutationResult;
2323
import com.google.firebase.firestore.util.AsyncQueue;
2424
import com.google.firebase.firestore.util.AsyncQueue.TimerId;
25-
import com.google.firebase.firestore.util.FirestoreChannel;
2625
import com.google.firestore.v1.FirestoreGrpc;
2726
import com.google.firestore.v1.WriteRequest;
2827
import com.google.firestore.v1.WriteResponse;

firebase-firestore/src/main/java/com/google/firebase/firestore/util/CustomClassMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ private Type resolveType(Type type, Map<TypeVariable<Class<T>>, Type> types) {
861861
}
862862

863863
Map<String, Object> serialize(T object, ErrorPath path) {
864+
// TODO(wuandy): Add logic to skip @DocumentId annotated fields in serialization.
864865
if (!clazz.isAssignableFrom(object.getClass())) {
865866
throw new IllegalArgumentException(
866867
"Can't serialize object of class "

firebase-firestore/src/test/java/com/google/firebase/firestore/util/MapperTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,6 @@ public void documentIdsDeserialize() {
24112411
@Test
24122412
public void documentIdsRoundTrip() {
24132413
// Implicitly verifies @DocumentId is ignored during serialization.
2414-
24152414
DocumentReference ref = TestUtil.documentReference("coll/doc123");
24162415

24172416
assertEquals(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
android.enableUnitTestBinaryResources=true
2+

0 commit comments

Comments
 (0)