From 22f6bd53e2d0cd18d6374cb2663a32f1de242436 Mon Sep 17 00:00:00 2001 From: Stevie Strickland Date: Fri, 5 Jan 2018 07:39:58 -0800 Subject: [PATCH] Use Error Prone and fix found mistakes. That only requires Java 6+, but also making an executive decision to make Java 7+ a prerequisite for the samples so we can use Java 7 features in future updates. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180925954 --- java/README.md | 4 ++-- java/pom.xml | 20 ++++++++++++++++--- .../java/shopping/common/Authenticator.java | 4 ++-- .../main/java/shopping/common/BaseSample.java | 2 +- .../shopping/common/BaseWorkflowSample.java | 3 ++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/java/README.md b/java/README.md index 196fbda..741fea4 100644 --- a/java/README.md +++ b/java/README.md @@ -8,7 +8,7 @@ the Google Content API for Shopping and/or the Manufacturer Center API. ## Prerequisites -Please make sure that you're running Java 5+. If you use Maven, you can use +Please make sure that you're running Java 7+. If you use Maven, you can use the included `pom.xml` to install the required dependencies. Otherwise, install the [Content API for Shopping Client Library for Java](https://developers.google.com/api-client-library/java/apis/content/v2) @@ -29,4 +29,4 @@ project appropriately for access to the Google APIs Client Library for Java. 1. Build and run any of the included samples. -2. Examine your shell output, be inspired and start hacking an amazing new app! +1. Examine your shell output, be inspired and start hacking an amazing new app! diff --git a/java/pom.xml b/java/pom.xml index 328147a..e4934c5 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -50,7 +50,7 @@ 3.0 - 1.5 + 1.7 @@ -62,9 +62,23 @@ maven-compiler-plugin 3.3 - 1.5 - 1.5 + javac-with-errorprone + true + 7 + 7 + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.7 + + + com.google.errorprone + error_prone_core + 2.1.2 + + org.codehaus.mojo diff --git a/java/src/main/java/shopping/common/Authenticator.java b/java/src/main/java/shopping/common/Authenticator.java index 48d33bf..d1e6435 100644 --- a/java/src/main/java/shopping/common/Authenticator.java +++ b/java/src/main/java/shopping/common/Authenticator.java @@ -96,13 +96,13 @@ public Credential authenticate() throws IOException { String userID = ConfigDataStoreFactory.UNUSED_ID; Credential storedCredential = flow.loadCredential(userID); if (storedCredential != null) { - System.out.printf("Retrieved stored credential%n", userID); + System.out.printf("Retrieved stored credential for %s from cache.%n", userID); return storedCredential; } LocalServerReceiver receiver = new LocalServerReceiver.Builder().setHost("localhost").setPort(9999).build(); Credential credential = new AuthorizationCodeInstalledApp(flow, receiver).authorize(userID); - System.out.printf("Retrieved credential from web%n", userID); + System.out.printf("Retrieved credential for %s from web.%n", userID); return credential; } catch (IOException e) { throw new IOException( diff --git a/java/src/main/java/shopping/common/BaseSample.java b/java/src/main/java/shopping/common/BaseSample.java index 6eb5f3d..b0f9a38 100644 --- a/java/src/main/java/shopping/common/BaseSample.java +++ b/java/src/main/java/shopping/common/BaseSample.java @@ -56,7 +56,7 @@ protected void checkGoogleJsonResponseException(GoogleJsonResponseException e) BaseWorkflowSample.checkGoogleJsonResponseException(e); } - protected T createService(T.Builder builder) { + protected T createService(AbstractGoogleClient.Builder builder) { return BaseWorkflowSample.createService(builder); } diff --git a/java/src/main/java/shopping/common/BaseWorkflowSample.java b/java/src/main/java/shopping/common/BaseWorkflowSample.java index bfbbe32..0e838b5 100644 --- a/java/src/main/java/shopping/common/BaseWorkflowSample.java +++ b/java/src/main/java/shopping/common/BaseWorkflowSample.java @@ -36,7 +36,8 @@ protected static void checkGoogleJsonResponseException(GoogleJsonResponseExcepti } } - protected static T createService(T.Builder builder) { + protected static T createService( + AbstractGoogleClient.Builder builder) { String endpoint = System.getenv(ENDPOINT_ENV_VAR); if (endpoint != null) { try {