Skip to content

Maven GAE plugin config updates #2442

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
Mar 20, 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
2 changes: 1 addition & 1 deletion cloud-sql/mysql/servlet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ environment variables into the runtime.

Next, the following command will deploy the application to your Google Cloud project:
```bash
mvn appengine:deploy
mvn clean package appengine:deploy
```

### Deploy to Cloud Run
Expand Down
2 changes: 1 addition & 1 deletion cloud-sql/mysql/servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion cloud-sql/postgres/servlet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ environment variables into the runtime.

Next, the following command will deploy the application to your Google Cloud project:
```bash
mvn appengine:deploy
mvn clean package appengine:deploy
```
2 changes: 1 addition & 1 deletion cloud-sql/postgres/servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion memorystore/redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion storage/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion storage/json-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion storage/s3-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
12 changes: 5 additions & 7 deletions storage/s3-sdk/src/main/java/ListGcsBuckets.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.Bucket;

import java.util.List;

public class ListGcsBuckets {
public static void listGcsBuckets(String googleAccessKeyId,
String googleAccessKeySecret) {
public static void listGcsBuckets(String googleAccessKeyId, String googleAccessKeySecret) {

// String googleAccessKeyId = "your-google-access-key-id";
// String googleAccessKeySecret = "your-google-access-key-secret";

// Create a BasicAWSCredentials using Cloud Storage HMAC credentials.
BasicAWSCredentials googleCreds = new BasicAWSCredentials(googleAccessKeyId,
googleAccessKeySecret);
BasicAWSCredentials googleCreds =
new BasicAWSCredentials(googleAccessKeyId, googleAccessKeySecret);

// Create a new client and do the following:
// 1. Change the endpoint URL to use the Google Cloud Storage XML API endpoint.
// 2. Use Cloud Storage HMAC Credentials.
AmazonS3 interopClient = AmazonS3ClientBuilder.standard()
AmazonS3 interopClient =
AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
"https://storage.googleapis.com", "auto"))
Expand All @@ -59,4 +58,3 @@ public static void listGcsBuckets(String googleAccessKeyId,
}
// [END storage_s3_sdk_list_buckets]
}

15 changes: 6 additions & 9 deletions storage/s3-sdk/src/main/java/ListGcsObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,32 @@
* limitations under the License.
*/


// [START storage_s3_sdk_list_objects]
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;

import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;

import java.util.List;

public class ListGcsObjects {
public static void listGcsObjects(String googleAccessKeyId,
String googleAccessKeySecret, String bucketName) {
public static void listGcsObjects(
String googleAccessKeyId, String googleAccessKeySecret, String bucketName) {

// String googleAccessKeyId = "your-google-access-key-id";
// String googleAccessKeySecret = "your-google-access-key-secret";
// String bucketName = "bucket-name";

// Create a BasicAWSCredentials using Cloud Storage HMAC credentials.
BasicAWSCredentials googleCreds = new BasicAWSCredentials(googleAccessKeyId,
googleAccessKeySecret);
BasicAWSCredentials googleCreds =
new BasicAWSCredentials(googleAccessKeyId, googleAccessKeySecret);

// Create a new client and do the following:
// 1. Change the endpoint URL to use the Google Cloud Storage XML API endpoint.
// 2. Use Cloud Storage HMAC Credentials.
AmazonS3 interopClient = AmazonS3ClientBuilder.standard()
AmazonS3 interopClient =
AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(
"https://storage.googleapis.com", "auto"))
Expand Down
1 change: 0 additions & 1 deletion storage/s3-sdk/src/test/java/ListGcsBucketsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.junit.Assert.assertThat;

import com.amazonaws.services.s3.model.Bucket;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
Expand Down
1 change: 0 additions & 1 deletion storage/s3-sdk/src/test/java/ListGcsObjectsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.ObjectListing;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion storage/storage-transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion storage/xml-api/cmdline-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.util.Preconditions;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.util.Collections;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
Expand Down
2 changes: 1 addition & 1 deletion storage/xml-api/serviceaccount-appengine-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Running and Deploying Your Application from the Command Line

To run your application locally on a development server:

mvn appengine:devserver
mvn appengine:run

To deploy your application to appspot.com:

Expand Down
10 changes: 6 additions & 4 deletions storage/xml-api/serviceaccount-appengine-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.11</version>
<version>1.0.12</version>
</parent>

<groupId>com.google.apis-samples</groupId>
Expand Down Expand Up @@ -82,14 +82,16 @@
</plugin>

<!--
The actual appengine-maven-plugin. Type "mvn appengine:devserver" to run project,
The actual appengine-maven-plugin. Type "mvn appengine:run" to run project,
"mvn appengine:update" to upload to GAE.
-->
<plugin>
<groupId>com.google.appengine</groupId>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.77</version>
<version>2.2.0</version>
<configuration>
<projectId>GCLOUD_CONFIG</projectId>
<version>gaeinfo</version>
<port>8888</port>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -46,8 +44,7 @@ public class StorageSample extends HttpServlet {
private static final int HTTP_OK = 200;

/** The base endpoint for Google Cloud Storage api calls. */
private static final String GCS_URI =
"http://commondatastorage.googleapis.com";
private static final String GCS_URI = "http://commondatastorage.googleapis.com";

/** Global configuration of Google Cloud Storage OAuth 2.0 scope. */
private static final String STORAGE_SCOPE =
Expand All @@ -65,35 +62,30 @@ protected void doGet(final HttpServletRequest req, final HttpServletResponse res
throws IOException {

try {
AppIdentityCredential credential = new AppIdentityCredential(
Arrays.asList(STORAGE_SCOPE));
AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(STORAGE_SCOPE));

// Set up and execute Google Cloud Storage request.
String bucketName = req.getRequestURI();
if (bucketName.equals("/")) {
resp.sendError(
HTTP_NOT_FOUND,
"No bucket specified - append /bucket-name to the URL and retry.");
HTTP_NOT_FOUND, "No bucket specified - append /bucket-name to the URL and retry.");
return;
}
// Remove any trailing slashes, if found.
//[START snippet]
// [START snippet]
String cleanBucketName = bucketName.replaceAll("/$", "");
String uri = GCS_URI + cleanBucketName;
HttpRequestFactory requestFactory =
HTTP_TRANSPORT.createRequestFactory(credential);
HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(credential);
GenericUrl url = new GenericUrl(uri);
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse response = request.execute();
String content = response.parseAsString();
//[END snippet]
// [END snippet]

// Display the output XML.
resp.setContentType("text/xml");
BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(resp.getOutputStream()));
String formattedContent = content.replaceAll(
"(<ListBucketResult)", XSL + "$1");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream()));
String formattedContent = content.replaceAll("(<ListBucketResult)", XSL + "$1");
writer.append(formattedContent);
writer.flush();
resp.setStatus(HTTP_OK);
Expand Down
Loading