Skip to content

Extract core encoders api into a separate library. #1930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ static void configure(
FirebaseLibraryExtension firebaseLibrary) {

Configuration javadocClasspath = project.getConfigurations().create("javadocClasspath");
javadocClasspath
.getAttributes()
.attribute(
BuildTypeAttr.ATTRIBUTE, project.getObjects().named(BuildTypeAttr.class, "release"));
if (android != null) {
javadocClasspath
.getAttributes()
.attribute(
BuildTypeAttr.ATTRIBUTE, project.getObjects().named(BuildTypeAttr.class, "release"));
}

project.afterEvaluate(
p -> {
Expand Down
82 changes: 0 additions & 82 deletions encoders/firebase-encoders-json/api.txt
Original file line number Diff line number Diff line change
@@ -1,86 +1,4 @@
// Signature format: 2.0
package com.google.firebase.encoders {

public interface DataEncoder {
method public void encode(@NonNull Object, @NonNull java.io.Writer) throws java.io.IOException;
method @NonNull public String encode(@NonNull Object);
}

public final class EncodingException extends java.lang.RuntimeException {
ctor public EncodingException(@NonNull String);
ctor public EncodingException(@NonNull String, @NonNull Exception);
}

public final class FieldDescriptor {
method @NonNull public static com.google.firebase.encoders.FieldDescriptor.Builder builder(@NonNull String);
method @NonNull public String getName();
method @Nullable public <T extends java.lang.annotation.Annotation> T getProperty(@NonNull Class<T>);
}

public static final class FieldDescriptor.Builder {
method @NonNull public com.google.firebase.encoders.FieldDescriptor build();
method @NonNull public <T extends java.lang.annotation.Annotation> com.google.firebase.encoders.FieldDescriptor.Builder withProperty(@NonNull T);
}

public interface ObjectEncoder<T> {
}

public interface ObjectEncoderContext {
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, @Nullable Object) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, double) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, int) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, long) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, boolean) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext inline(@Nullable Object) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext nested(@NonNull String) throws java.io.IOException;
}

public interface ValueEncoder<T> {
}

public interface ValueEncoderContext {
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(@Nullable String) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(double) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(int) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(long) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(boolean) throws java.io.IOException;
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(@NonNull byte[]) throws java.io.IOException;
}

}

package com.google.firebase.encoders.annotations {

@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) public @interface Encodable {
}

@java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) public static @interface Encodable.Field {
method public abstract boolean inline() default false;
method public abstract String name() default "";
}

@java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) public static @interface Encodable.Ignore {
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target(java.lang.annotation.ElementType.ANNOTATION_TYPE) public @interface ExtraProperty {
method public abstract Class<?>[] allowedTypes() default {};
}

}

package com.google.firebase.encoders.config {

public interface Configurator {
method public void configure(@NonNull com.google.firebase.encoders.config.EncoderConfig<?>);
}

public interface EncoderConfig<T extends com.google.firebase.encoders.config.EncoderConfig<T>> {
method @NonNull public <U> T registerEncoder(@NonNull Class<U>, @NonNull com.google.firebase.encoders.ObjectEncoder<? super U>);
method @NonNull public <U> T registerEncoder(@NonNull Class<U>, @NonNull com.google.firebase.encoders.ValueEncoder<? super U>);
}

}

package com.google.firebase.encoders.json {

public final class JsonDataEncoderBuilder implements com.google.firebase.encoders.config.EncoderConfig<com.google.firebase.encoders.json.JsonDataEncoderBuilder> {
Expand Down
15 changes: 6 additions & 9 deletions encoders/firebase-encoders-json/firebase-encoders-json.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,18 @@ android {
includeAndroidResources = true
}
}

sourceSets.main.java {
srcDir 'src/json/java'
}
}

dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
implementation project(':encoders:firebase-encoders')

testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test:runner:1.3.0'
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation 'junit:junit:4.13-rc-1'
testImplementation "com.google.truth:truth:$googleTruthVersion"
testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'junit:junit:4.13'
testImplementation "com.google.truth:truth:1.0.1"
testImplementation 'org.mockito:mockito-core:3.3.3'

}

Expand Down
2 changes: 1 addition & 1 deletion encoders/firebase-encoders-json/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version=16.1.1
version=17.0.0
latestReleasedVersion=16.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ def jvm = org.gradle.internal.jvm.Jvm.current()


dependencies {
implementation project(':encoders:firebase-encoders-processor:test-support')
implementation project(':encoders:firebase-encoders')
implementation 'com.google.auto.service:auto-service-annotations:1.0-rc6'
implementation 'com.squareup:javapoet:1.11.1'
implementation 'com.squareup:javapoet:1.13.0'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
implementation 'com.google.guava:guava:28.1-jre'

implementation "com.google.auto.value:auto-value-annotations:1.6.5"
implementation "com.google.auto.value:auto-value-annotations:1.6.6"

annotationProcessor "com.google.auto.value:auto-value:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.5"

annotationProcessor 'com.google.auto.service:auto-service:1.0-rc6'

testImplementation 'com.google.testing.compile:compile-testing:0.18'
if (jvm.getToolsJar() != null) testImplementation files(jvm.getToolsJar())
testImplementation 'com.google.truth:truth:1.0'
testImplementation 'com.google.truth:truth:1.0.1'

}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ android {

dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
implementation project(':encoders:firebase-encoders')
implementation project(':encoders:firebase-encoders-json')

testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test:runner:1.3.0'
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation "org.robolectric:robolectric:$robolectricVersion"
testImplementation 'junit:junit:4.13-rc-1'
testImplementation "com.google.truth:truth:$googleTruthVersion"
testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'junit:junit:4.13'
testImplementation 'com.google.truth:truth:1.0.1'
testImplementation 'org.mockito:mockito-core:3.3.3'

}
86 changes: 86 additions & 0 deletions encoders/firebase-encoders/api.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Signature format: 2.0
package com.google.firebase.encoders {

public interface DataEncoder {
method public void encode(@NonNull Object, @NonNull Writer);
method @NonNull public String encode(@NonNull Object);
}

public final class EncodingException {
ctor public EncodingException(@NonNull String);
ctor public EncodingException(@NonNull String, @NonNull Exception);
}

public final class FieldDescriptor {
method @NonNull public static com.google.firebase.encoders.FieldDescriptor.Builder builder(@NonNull String);
method public boolean equals(Object);
method @NonNull public String getName();
method @Nullable public <T extends Annotation> T getProperty(@NonNull Class<T>);
method public int hashCode();
method @NonNull public String toString();
}

public static final class FieldDescriptor.Builder {
method @NonNull public com.google.firebase.encoders.FieldDescriptor build();
method @NonNull public <T extends Annotation> com.google.firebase.encoders.FieldDescriptor.Builder withProperty(@NonNull T);
}

public interface ObjectEncoder<T> {
}

public interface ObjectEncoderContext {
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, @Nullable Object);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, double);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, int);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, long);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext add(@NonNull String, boolean);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext inline(@Nullable Object);
method @NonNull public com.google.firebase.encoders.ObjectEncoderContext nested(@NonNull String);
}

public interface ValueEncoder<T> {
}

public interface ValueEncoderContext {
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(@Nullable String);
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(double);
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(int);
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(long);
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(boolean);
method @NonNull public com.google.firebase.encoders.ValueEncoderContext add(@NonNull byte[]);
}

}

package com.google.firebase.encoders.annotations {

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface Encodable {
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface Encodable.Field {
method public abstract boolean inline() default false;
method public abstract String name() default "";
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface Encodable.Ignore {
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface ExtraProperty {
method public abstract Class<?>[] allowedTypes() default {};
}

}

package com.google.firebase.encoders.config {

public interface Configurator {
method public void configure(@NonNull com.google.firebase.encoders.config.EncoderConfig<?>);
}

public interface EncoderConfig<T extends com.google.firebase.encoders.config.EncoderConfig<T>> {
method @NonNull public <U> T registerEncoder(@NonNull Class<U>, @NonNull com.google.firebase.encoders.ObjectEncoder<? super U>);
method @NonNull public <U> T registerEncoder(@NonNull Class<U>, @NonNull com.google.firebase.encoders.ValueEncoder<? super U>);
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,28 @@
// limitations under the License.

plugins {
id 'java-library'
id 'firebase-java-library'
}

firebaseLibrary {
publishSources = true
publishJavadoc = false
}

java {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}


dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
}

testImplementation 'junit:junit:4.13'
testImplementation "com.google.truth:truth:$googleTruthVersion"

}

tasks.withType(JavaCompile) {
options.compilerArgs << "-Werror"
}
15 changes: 15 additions & 0 deletions encoders/firebase-encoders/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2019 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.

version=16.0.0
1 change: 1 addition & 0 deletions firebase-crashlytics/firebase-crashlytics.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ thirdPartyLicenses {
dependencies {
compileOnly 'com.google.auto.value:auto-value-annotations:1.6.5'

implementation project(':encoders:firebase-encoders')
implementation project(':encoders:firebase-encoders-json')
implementation project(':firebase-common')
implementation project(':firebase-components')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {
implementation project(':transport:transport-api')
implementation project(':transport:transport-runtime')
implementation project(':transport:transport-backend-cct')
implementation project(':encoders:firebase-encoders')
implementation project(':encoders:firebase-encoders-json')

implementation 'androidx.annotation:annotation:1.1.0'
Expand Down
1 change: 1 addition & 0 deletions firebase-messaging/firebase-messaging.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies {
implementation project(':transport:transport-api')
implementation project(':transport:transport-runtime')
implementation project(':transport:transport-backend-cct')
implementation project(':encoders:firebase-encoders')
implementation project(':encoders:firebase-encoders-json')

implementation 'androidx.annotation:annotation:1.1.0'
Expand Down
2 changes: 1 addition & 1 deletion subprojects.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ firebase-storage:test-app
protolite-well-known-types

encoders
encoders:firebase-encoders
encoders:firebase-encoders-json
encoders:firebase-encoders-processor
encoders:firebase-encoders-processor:test-support
encoders:firebase-encoders-reflective
encoders:firebase-decoders-json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ android {
dependencies {
implementation project(':transport:transport-api')
implementation project(':transport:transport-runtime')
implementation project(':encoders:firebase-encoders')
implementation project(':encoders:firebase-encoders-json')
implementation 'androidx.annotation:annotation:1.1.0'

Expand Down