Skip to content

Upgrade gJF and remove global config for gJF. #2745

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 1 commit into from
Jun 18, 2021
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
21 changes: 0 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,6 @@ configure(subprojects) {
}
}

apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.7'
}
tasks.googleJavaFormat {
source '.'
include '**/java/**/*.java'
exclude '**/generated/**'
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/Assert.java'
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/ThrowingRunnable.java'
exclude '**/package-info.java'
}
tasks.verifyGoogleJavaFormat {
source '.'
include '**/java/**/*.java'
exclude '**/generated/**'
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/Assert.java'
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/ThrowingRunnable.java'
exclude '**/package-info.java'
}

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

Expand Down
6 changes: 5 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ repositories {
maven {
url 'https://storage.googleapis.com/android-ci/mvn/'
}
maven {
url 'https://plugins.gradle.org/m2/'
}
}

// Refer latest "perf-plugin" released version on https://maven.google.com/web/index.html?q=perf-plugin#com.google.firebase:perf-plugin
Expand All @@ -37,7 +40,7 @@ repositories {
def perfPluginVersion = System.getenv("FIREBASE_PERF_PLUGIN_VERSION") ?: "1.4.0"

googleJavaFormat {
toolVersion = '1.7'
toolVersion = '1.10.0'
}

dependencies {
Expand All @@ -64,6 +67,7 @@ dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
implementation 'org.jetbrains.dokka:dokka-android-gradle-plugin:0.9.17-g013-9b8280a'
implementation 'com.android.tools.build:gradle:3.4.3'
implementation 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'

testImplementation 'junit:junit:4.13.2'
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.firebase.gradle.plugins;

import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormatExtension;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.firebase.gradle.plugins.apiinfo.ApiInformationTask;
Expand All @@ -37,6 +38,9 @@ public class FirebaseJavaLibraryPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.apply(ImmutableMap.of("plugin", "java-library"));
project.apply(ImmutableMap.of("plugin", "com.github.sherter.google-java-format"));
project.getExtensions().getByType(GoogleJavaFormatExtension.class).setToolVersion("1.10.0");

FirebaseLibraryExtension firebaseLibrary =
project
.getExtensions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.android.build.gradle.LibraryExtension;
import com.android.build.gradle.api.AndroidSourceSet;
import com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormatExtension;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.firebase.gradle.plugins.apiinfo.ApiInformationTask;
Expand All @@ -42,6 +43,8 @@ public class FirebaseLibraryPlugin implements Plugin<Project> {
public void apply(Project project) {
project.apply(ImmutableMap.of("plugin", "com.android.library"));
project.apply(ImmutableMap.of("plugin", LicenseResolverPlugin.class));
project.apply(ImmutableMap.of("plugin", "com.github.sherter.google-java-format"));
project.getExtensions().getByType(GoogleJavaFormatExtension.class).setToolVersion("1.10.0");

FirebaseLibraryExtension firebaseLibrary =
project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,21 @@ private static Map<String, String> getDependencyTypes(FirebaseLibraryExtension f
Configuration dummyDependencyConfiguration =
project.getConfigurations().create("publisherDummyConfig");
Set<Dependency> nonProjectDependencies =
project.getConfigurations().getByName(firebaseLibrary.getRuntimeClasspath())
.getAllDependencies().stream()
project
.getConfigurations()
.getByName(firebaseLibrary.getRuntimeClasspath())
.getAllDependencies()
.stream()
.filter(dep -> !(dep instanceof ProjectDependency))
.collect(Collectors.toSet());

dummyDependencyConfiguration.getDependencies().addAll(nonProjectDependencies);
try {
return project.getConfigurations().getByName(firebaseLibrary.getRuntimeClasspath())
.getAllDependencies().stream()
return project
.getConfigurations()
.getByName(firebaseLibrary.getRuntimeClasspath())
.getAllDependencies()
.stream()
.map(dep -> getType(dummyDependencyConfiguration, dep))
.filter(Objects::nonNull)
.collect(Collectors.toMap(lib -> lib.name, lib -> lib.type.getFormat()));
Expand Down
1 change: 1 addition & 0 deletions encoders/encoders.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

configure(subprojects) {
group = 'com.google.firebase'
apply plugin: 'com.github.sherter.google-java-format'
}

Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ dependencies {

test {
testLogging.showStandardStreams = true
}

googleJavaFormat {
exclude 'src/test/resources/**'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
// See the License for the specific language governing permissions and
// limitations under the License.
/** @hide */
package com.google.firebase.dynamicloading;
package com.google.firebase.dynamicloading;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@
// limitations under the License.

/** @hide */

package com.google.firebase.remoteconfig.internal;


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

/** @hide */
package com.google.firebase.crashlytics.ndk;
package com.google.firebase.crashlytics.ndk;
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ private void persistEvent(

if (!sortedCustomAttributes.isEmpty()) {
eventBuilder.setApp(
capturedEvent
.getApp()
.toBuilder()
capturedEvent.getApp().toBuilder()
.setCustomAttributes(ImmutableList.from(sortedCustomAttributes))
.setInternalKeys(ImmutableList.from(sortedInternalKeys))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ public void testSetSessionIdUtf8Bytes_returnsProperSessionId() {
assertNotEquals(testSessionId, testReport.getSession().getIdentifier());

final CrashlyticsReport updatedReport =
testReport
.toBuilder()
testReport.toBuilder()
.setSession(
testReport.getSession().toBuilder().setIdentifierFromUtf8Bytes(utf8Bytes).build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ public boolean equals(Object other) {
public int hashCode() {
return spec.hashCode();
}
};
}

public void keepSynced(final QuerySpec query, final boolean keep) {
if (keep && !keepSyncedQueries.contains(query)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static final String predecessor(String key) {
return next.append(
new String(new char[MAX_KEY_LEN - next.length()]).replace("\0", "" + MAX_PUSH_CHAR))
.toString();
};
}

public static final String successor(String key) {
Validation.validateNullableKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/** @hide */
package com.google.firebase.datatransport;
package com.google.firebase.datatransport;
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/** @hide */
package com.google.firebase.dynamiclinks.internal;
package com.google.firebase.dynamiclinks.internal;
5 changes: 5 additions & 0 deletions firebase-firestore/firebase-firestore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ configurations.all {
exclude group: "com.google.protobuf", module: "protobuf-java"
}

googleJavaFormat {
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/Assert.java'
exclude 'src/testUtil/java/com/google/firebase/firestore/testutil/ThrowingRunnable.java'
}

dependencies {
implementation project(':firebase-common')
implementation project(':protolite-well-known-types')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ private void rewriteCanonicalIds() {
throw fail("Failed to decode Query data for target %s", targetId);
}
});
};
}

private void createBundleCache() {
ifTablesDontExist(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class DeveloperListenerManager {
private Map<FirebaseInAppMessagingDismissListener, DismissExecutorAndListener>
registeredDismissListeners = new HashMap<>();
private Map<FirebaseInAppMessagingDisplayErrorListener, ErrorsExecutorAndListener>
registeredErrorListeners = new HashMap<>();;
registeredErrorListeners = new HashMap<>();
private Map<FirebaseInAppMessagingImpressionListener, ImpressionExecutorAndListener>
registeredImpressionListeners = new HashMap<>();;
registeredImpressionListeners = new HashMap<>();

private static BlockingQueue<Runnable> mCallbackQueue = new LinkedBlockingQueue<>();
private static final ThreadPoolExecutor CALLBACK_QUEUE_EXECUTOR =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ public void setup() throws NameNotFoundException {
doNothing().when(providerInstaller).install();
clock = new FakeClock(new SystemClock().now());
testFetchEligibleCampaignsResponse =
testFetchEligibleCampaignsResponse
.toBuilder()
testFetchEligibleCampaignsResponse.toBuilder()
.setExpirationEpochTimestampMillis(clock.now() + TimeUnit.MINUTES.toMillis(5))
.build();

Expand Down Expand Up @@ -296,8 +295,7 @@ public void getFiams_clientAppInfoContainsGmpAppId() {
public void getFiams_protectsFromBadPastCacheTimestamp() {
// The expiration timestamp is set to duration of 1 day NOT the timestamp of now+1day
FetchEligibleCampaignsResponse badCacheTimestamp =
testFetchEligibleCampaignsResponse
.toBuilder()
testFetchEligibleCampaignsResponse.toBuilder()
.setExpirationEpochTimestampMillis(TimeUnit.DAYS.toMillis(1))
.build();

Expand All @@ -317,8 +315,7 @@ public void getFiams_protectsFromBadPastCacheTimestamp() {
public void getFiams_protectsFromFutureBadCacheTimestamp() {
// The expiration timestamp is set to duration of 1 day NOT the timestamp of now+1day
FetchEligibleCampaignsResponse badCacheTimestamp =
testFetchEligibleCampaignsResponse
.toBuilder()
testFetchEligibleCampaignsResponse.toBuilder()
.setExpirationEpochTimestampMillis(
clock.now() + TimeUnit.DAYS.toMillis(3) + TimeUnit.SECONDS.toMillis(1))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ public void testFidListener_fidChanged_successful() throws Exception {
when(mockBackend.createFirebaseInstallation(
anyString(), anyString(), anyString(), anyString(), any()))
.thenReturn(
TEST_INSTALLATION_RESPONSE
.toBuilder()
TEST_INSTALLATION_RESPONSE.toBuilder()
.setUri("/projects/" + TEST_PROJECT_ID + "/installations/" + TEST_FID_2)
.setFid(TEST_FID_2)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void onSendError(@NonNull String msgId, @NonNull Exception exception) {}
* com.google.firebase.iid.FirebaseInstanceId#getInstanceId()}.
*/
@WorkerThread
public void onNewToken(@NonNull String token) {};
public void onNewToken(@NonNull String token) {}

/** @hide */
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@

/** @hide */
package com.google.firebase.perf.util;

Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public void testAbsenceOfRequiredFieldsOnAndroidApplicationInfoFailsValidation()
// All required fields present.
assertThat(
new FirebasePerfApplicationInfoValidator(
validApplicationInfo
.toBuilder()
validApplicationInfo.toBuilder()
.setAndroidAppInfo(
AndroidApplicationInfo.newBuilder()
.setPackageName("validPackageName")
Expand All @@ -75,8 +74,7 @@ public void testAbsenceOfRequiredFieldsOnAndroidApplicationInfoFailsValidation()
// Package name missing.
assertThat(
new FirebasePerfApplicationInfoValidator(
validApplicationInfo
.toBuilder()
validApplicationInfo.toBuilder()
.setAndroidAppInfo(AndroidApplicationInfo.newBuilder().setSdkVersion("1.3"))
.build())
.isValidPerfMetric())
Expand All @@ -85,8 +83,7 @@ public void testAbsenceOfRequiredFieldsOnAndroidApplicationInfoFailsValidation()
// SDK Version missing.
assertThat(
new FirebasePerfApplicationInfoValidator(
validApplicationInfo
.toBuilder()
validApplicationInfo.toBuilder()
.setAndroidAppInfo(
AndroidApplicationInfo.newBuilder().setPackageName("validPackageName"))
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class MockConnectionFactory implements HttpURLConnectionFactory {
private final Semaphore pauseSemaphore = new Semaphore(0);
private int lineCount = 0;
private int pauseRecord = Integer.MAX_VALUE;
private int currentRecord = 0;;
private int currentRecord = 0;

public MockConnectionFactory(String testName, boolean binaryBody) {
this.binaryBody = binaryBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/** @hide */
package com.google.android.datatransport;
package com.google.android.datatransport;
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ private static int getPackageVersionCode(Context context) {
public EventInternal decorate(EventInternal eventInternal) {
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

return eventInternal
.toBuilder()
return eventInternal.toBuilder()
.addMetadata(KEY_SDK_VERSION, Build.VERSION.SDK_INT)
.addMetadata(KEY_MODEL, Build.MODEL)
.addMetadata(KEY_HARDWARE, Build.HARDWARE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
// limitations under the License.

/** @hide */
package com.google.android.datatransport.cct;
package com.google.android.datatransport.cct;
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,14 @@ public void setUp() {
.thenAnswer(
(Answer<EventInternal>)
invocation ->
invocation
.<EventInternal>getArgument(0)
.toBuilder()
invocation.<EventInternal>getArgument(0).toBuilder()
.addMetadata(TEST_KEY, TEST_VALUE)
.build());
when(mockBackend2.decorate(any()))
.thenAnswer(
(Answer<EventInternal>)
invocation ->
invocation
.<EventInternal>getArgument(0)
.toBuilder()
invocation.<EventInternal>getArgument(0).toBuilder()
.addMetadata(TEST_KEY, TEST_VALUE)
.build());
/*
Expand Down
Loading