Skip to content

Enable errorprone only by request. #1461

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 2 commits into from
Apr 16, 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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ Firebase Android libraries exercise all three types of tests recommended by the
Depending on the requirements of the specific project, some or all of these
tests may be used to support changes.

> :warning: **Running tests with errorprone**
>
> To run with errorprone add `withErrorProne` to the command line, e.g.
>
> `./gradlew :<firebase-project>:check withErrorProne`.

### Unit Testing

These are tests that run on your machine's local Java Virtual Machine (JVM). At
Expand Down
12 changes: 1 addition & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ buildscript {
}

apply from: 'sdkProperties.gradle'
apply from: "gradle/errorProne.gradle"

ext {
playServicesVersion = '16.0.1'
supportAnnotationsVersion = '28.0.0'
errorproneVersion = '2.3.2'
errorproneJavacVersion = '9+181-r4173-1'
googleTruthVersion = '0.45'
robolectricVersion = '4.1'
}
Expand All @@ -72,12 +71,7 @@ configure(subprojects) {
jcenter()
mavenLocal()
}
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone "com.google.errorprone:error_prone_core:$errorproneVersion"
errorproneJavac "com.google.errorprone:javac:$errorproneJavacVersion"

}
apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.7'
Expand All @@ -99,10 +93,6 @@ configure(subprojects) {
exclude '**/package-info.java'
}

tasks.withType(JavaCompile) {
options.errorprone.excludedPaths = '.*/build/generated/.*'
}

apply plugin: "org.jlleitschuh.gradle.ktlint"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package com.google.firebase.abt;

import static com.google.firebase.abt.AbtExperimentInfo.validateAbtExperimentInfo;
import static com.google.firebase.abt.FirebaseABTesting.OriginService.INAPP_MESSAGING;
import static com.google.firebase.abt.FirebaseABTesting.OriginService.REMOTE_CONFIG;

import android.content.Context;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -67,7 +65,7 @@ public class FirebaseABTesting {
* Select keys of fields in the experiment descriptions returned from the Firebase Remote Config
* server.
*/
@StringDef({REMOTE_CONFIG, INAPP_MESSAGING})
@StringDef({OriginService.REMOTE_CONFIG, OriginService.INAPP_MESSAGING})
@Retention(RetentionPolicy.SOURCE)
public @interface OriginService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@

package com.google.firebase.remoteconfig;

import static com.google.firebase.remoteconfig.RemoteConfigConstants.ExperimentDescriptionFieldKey.EXPERIMENT_ID;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.ExperimentDescriptionFieldKey.VARIANT_ID;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.ANALYTICS_USER_PROPERTIES;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.APP_ID;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.APP_VERSION;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.COUNTRY_CODE;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.INSTANCE_ID;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.INSTANCE_ID_TOKEN;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.LANGUAGE_CODE;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.PACKAGE_NAME;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.PLATFORM_VERSION;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.SDK_VERSION;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.RequestFieldKey.TIME_ZONE;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.ResponseFieldKey.ENTRIES;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.ResponseFieldKey.EXPERIMENT_DESCRIPTIONS;
import static com.google.firebase.remoteconfig.RemoteConfigConstants.ResponseFieldKey.STATE;

import androidx.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -41,7 +24,7 @@
* @author Lucas Png
* @hide
*/
public class RemoteConfigConstants {
public final class RemoteConfigConstants {
public static final String FETCH_REGEX_URL =
"https://firebaseremoteconfig.googleapis.com/v1/projects/%s/namespaces/%s:fetch";

Expand All @@ -50,17 +33,17 @@ public class RemoteConfigConstants {
* server.
*/
@StringDef({
INSTANCE_ID,
INSTANCE_ID_TOKEN,
APP_ID,
COUNTRY_CODE,
LANGUAGE_CODE,
PLATFORM_VERSION,
TIME_ZONE,
APP_VERSION,
PACKAGE_NAME,
SDK_VERSION,
ANALYTICS_USER_PROPERTIES
RequestFieldKey.INSTANCE_ID,
RequestFieldKey.INSTANCE_ID_TOKEN,
RequestFieldKey.APP_ID,
RequestFieldKey.COUNTRY_CODE,
RequestFieldKey.LANGUAGE_CODE,
RequestFieldKey.PLATFORM_VERSION,
RequestFieldKey.TIME_ZONE,
RequestFieldKey.APP_VERSION,
RequestFieldKey.PACKAGE_NAME,
RequestFieldKey.SDK_VERSION,
RequestFieldKey.ANALYTICS_USER_PROPERTIES
})
@Retention(RetentionPolicy.SOURCE)
public @interface RequestFieldKey {
Expand All @@ -78,7 +61,11 @@ public class RemoteConfigConstants {
}

/** Keys of fields in the Fetch response body from the Firebase Remote Config server. */
@StringDef({ENTRIES, EXPERIMENT_DESCRIPTIONS, STATE})
@StringDef({
ResponseFieldKey.ENTRIES,
ResponseFieldKey.EXPERIMENT_DESCRIPTIONS,
ResponseFieldKey.STATE
})
@Retention(RetentionPolicy.SOURCE)
public @interface ResponseFieldKey {
String ENTRIES = "entries";
Expand All @@ -90,7 +77,10 @@ public class RemoteConfigConstants {
* Select keys of fields in the experiment descriptions returned from the Firebase Remote Config
* server.
*/
@StringDef({EXPERIMENT_ID, VARIANT_ID})
@StringDef({
ExperimentDescriptionFieldKey.EXPERIMENT_ID,
ExperimentDescriptionFieldKey.VARIANT_ID
})
@Retention(RetentionPolicy.SOURCE)
public @interface ExperimentDescriptionFieldKey {
String EXPERIMENT_ID = "experimentId";
Expand Down
35 changes: 35 additions & 0 deletions gradle/errorProne.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2020 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.

def isErrorProneRequested = getGradle().getStartParameter().getTaskNames().contains("withErrorProne")

def errorproneVersion = '2.3.2'
def errorproneJavacVersion = '9+181-r4173-1'

if (isErrorProneRequested) {
configure(subprojects) {
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone "com.google.errorprone:error_prone_core:$errorproneVersion"
errorproneJavac "com.google.errorprone:javac:$errorproneJavacVersion"

}
tasks.withType(JavaCompile) {
options.errorprone.excludedPaths = '.*/build/generated/.*'
}
}
}

// marker task to enable errorprone diagnostics.
task withErrorProne {}