Skip to content

Commit

Permalink
Use Error Prone and fix found mistakes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sstrickl committed Jan 10, 2018
1 parent 2931f39 commit 22f6bd5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions java/README.md
Expand Up @@ -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)
Expand All @@ -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!
20 changes: 17 additions & 3 deletions java/pom.xml
Expand Up @@ -50,7 +50,7 @@
<version>3.0</version>
</requireMavenVersion>
<requireJavaVersion>
<version>1.5</version>
<version>1.7</version>
</requireJavaVersion>
</rules>
</configuration>
Expand All @@ -62,9 +62,23 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<compilerId>javac-with-errorprone</compilerId>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
<source>7</source>
<target>7</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac-errorprone</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.1.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
4 changes: 2 additions & 2 deletions java/src/main/java/shopping/common/Authenticator.java
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/shopping/common/BaseSample.java
Expand Up @@ -56,7 +56,7 @@ protected void checkGoogleJsonResponseException(GoogleJsonResponseException e)
BaseWorkflowSample.checkGoogleJsonResponseException(e);
}

protected <T extends AbstractGoogleClient> T createService(T.Builder builder) {
protected <T extends AbstractGoogleClient> T createService(AbstractGoogleClient.Builder builder) {
return BaseWorkflowSample.createService(builder);
}

Expand Down
3 changes: 2 additions & 1 deletion java/src/main/java/shopping/common/BaseWorkflowSample.java
Expand Up @@ -36,7 +36,8 @@ protected static void checkGoogleJsonResponseException(GoogleJsonResponseExcepti
}
}

protected static <T extends AbstractGoogleClient> T createService(T.Builder builder) {
protected static <T extends AbstractGoogleClient> T createService(
AbstractGoogleClient.Builder builder) {
String endpoint = System.getenv(ENDPOINT_ENV_VAR);
if (endpoint != null) {
try {
Expand Down

0 comments on commit 22f6bd5

Please sign in to comment.