From 3de7fcea714c4defff1b33c212c1ecba792b42e8 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Fri, 3 Nov 2017 08:48:50 -0700 Subject: [PATCH 01/10] Add skeleton endpoints-frameworks v2 sample --- .../endpoints-v2-skeleton/README.md | 7 + .../endpoints-v2-skeleton/build.gradle | 84 ++++++++++++ appengine-java8/endpoints-v2-skeleton/pom.xml | 124 ++++++++++++++++++ .../main/java/com/example/skeleton/MyApi.java | 30 +++++ .../src/main/webapp/WEB-INF/appengine-web.xml | 28 ++++ .../main/webapp/WEB-INF/logging.properties | 25 ++++ .../src/main/webapp/WEB-INF/web.xml | 36 +++++ 7 files changed, 334 insertions(+) create mode 100644 appengine-java8/endpoints-v2-skeleton/README.md create mode 100644 appengine-java8/endpoints-v2-skeleton/build.gradle create mode 100644 appengine-java8/endpoints-v2-skeleton/pom.xml create mode 100644 appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java create mode 100644 appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml create mode 100644 appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/logging.properties create mode 100644 appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/web.xml diff --git a/appengine-java8/endpoints-v2-skeleton/README.md b/appengine-java8/endpoints-v2-skeleton/README.md new file mode 100644 index 00000000000..2c4e4329054 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/README.md @@ -0,0 +1,7 @@ +# App Engine Standard & Endpoints Frameworks Hello World + +This is a skeleton example for getting setup with Endpoints Framework v2 for +Java. + +For a more complete example of using Endpoints Framework v2 for Java review +the [backend example](/appengine-java8/endpoints-v2-backend). diff --git a/appengine-java8/endpoints-v2-skeleton/build.gradle b/appengine-java8/endpoints-v2-skeleton/build.gradle new file mode 100644 index 00000000000..e27f29b1747 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/build.gradle @@ -0,0 +1,84 @@ +// Copyright 2017 Google Inc. +// +// 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.import org.apache.tools.ant.filters.ReplaceTokens + +// [START build_script] +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2' + classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3' + } +} +// [END build_script] + +repositories { + mavenCentral() +} + +// [START plugin_applys] +apply plugin: 'java' +apply plugin: 'war' +apply plugin: 'com.google.cloud.tools.endpoints-framework-server' +apply plugin: 'com.google.cloud.tools.appengine' +// [END plugin_applys] + +// [START dependencies] +dependencies { + compile 'com.google.endpoints:endpoints-framework:2.0.8' + compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59' + + compile 'javax.inject:javax.inject:1' + compileOnly 'javax.servlet:javax.servlet-api:3.1.0' +} +// [END dependencies] + +def projectId = 'YOUR_PROJECT_ID' + +// [START endpoints_server_configuration] +endpointsServer { + // Endpoints Framework Plugin server-side configuration + hostname = "${projectId}.appspot.com" +} +// [END endpoints_server_configuration] + +appengine { // App Engine tasks configuration + deploy { // deploy configuration + version = findProperty("appengine.deploy.version") + + def promoteProp = findProperty("appengine.deploy.promote") + if (promoteProp != null) { + promote = new Boolean(promoteProp) + } + } +} + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +task wrapper(type: Wrapper) { + gradleVersion = '3.5' +} + +// this replaces the ${endpoints.project.id} in appengine-web.xml and web.xml +task replaceProjectId(type: Copy) { + from 'src/main/webapp/WEB-INF/' + include '*.xml' + into "build/exploded-${archivesBaseName}/WEB-INF" + expand(endpoints:[project:[id:projectId]]) + filteringCharset = 'UTF-8' +} +assemble.dependsOn replaceProjectId diff --git a/appengine-java8/endpoints-v2-skeleton/pom.xml b/appengine-java8/endpoints-v2-skeleton/pom.xml new file mode 100644 index 00000000000..5bc7ff2c262 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -0,0 +1,124 @@ + + + 4.0.0 + war + 1.0-SNAPSHOT + + com.example.skeleton + endpoints-j8-skeleton + + + appengine-java8-samples + com.google.cloud + 1.0.0 + .. + + + + UTF-8 + + 1.8 + 1.8 + + + + + + + com.google.endpoints + endpoints-framework + 2.0.9 + + + com.google.appengine + appengine-api-1.0-sdk + 1.9.59 + + + javax.servlet + javax.servlet-api + 3.1.0 + jar + provided + + + javax.inject + javax.inject + 1 + + + + + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + ${basedir}/src/main/webapp/WEB-INF + true + WEB-INF + + + + + + com.google.cloud.tools + appengine-maven-plugin + 1.3.1 + + + + + + com.google.cloud.tools + endpoints-framework-maven-plugin + 1.0.2 + + + YOUR-PROJECT-ID.appspot.com + + + + + org.codehaus.mojo + versions-maven-plugin + 2.3 + + + compile + + display-dependency-updates + display-plugin-updates + + + + + + + + + diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java b/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java new file mode 100644 index 00000000000..eae8f5fb82a --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 Google Inc. + * + * 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. + */ + +package com.example.skeleton; + +import com.google.api.server.spi.config.Api; + +/** + * MyApi skeleton endpoints sample + * Add your first API methods in this class, or you may create another class. + * In that case, update your src/main/webapp/WEB-INF/web.xml accordingly. + */ +@Api(name = "skeleton-api", + version = "v1") +public class MyApi { +} + diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 00000000000..b1ed8cb4a13 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,28 @@ + + + + java8 + true + + + 2 + + + + + + diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/logging.properties b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/logging.properties new file mode 100644 index 00000000000..0c2d58bdc34 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/logging.properties @@ -0,0 +1,25 @@ +# Copyright 2017 Google Inc. +# +# 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. + +# A default java.util.logging configuration. +# (All App Engine logging is through java.util.logging by default). +# +# To use this configuration, copy it into your application's WEB-INF +# folder and add the following to your appengine-web.xml: +# +# +# +# +# + +# Set the default logging level for all loggers to WARNING +.level = WARNING diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/web.xml b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..432a2a4af45 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,36 @@ + + + + + + EndpointsServlet + com.google.api.server.spi.EndpointsServlet + + services + com.example.skeleton.MyApi + + + + + EndpointsServlet + /_ah/api/* + + From a2361b8996898ca1704be8ef2e5905c959ba6371 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Mon, 13 Nov 2017 16:05:34 -0800 Subject: [PATCH 02/10] Rename README --- appengine-java8/endpoints-v2-skeleton/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appengine-java8/endpoints-v2-skeleton/README.md b/appengine-java8/endpoints-v2-skeleton/README.md index 2c4e4329054..deb996b5910 100644 --- a/appengine-java8/endpoints-v2-skeleton/README.md +++ b/appengine-java8/endpoints-v2-skeleton/README.md @@ -1,4 +1,4 @@ -# App Engine Standard & Endpoints Frameworks Hello World +# App Engine Standard & Endpoints Frameworks skeleton This is a skeleton example for getting setup with Endpoints Framework v2 for Java. From e9772a55165845cf0f4bf9b1a1d92630743ec920 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Mon, 13 Nov 2017 16:12:45 -0800 Subject: [PATCH 03/10] Fix version --- appengine-java8/endpoints-v2-skeleton/build.gradle | 2 +- appengine-java8/endpoints-v2-skeleton/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appengine-java8/endpoints-v2-skeleton/build.gradle b/appengine-java8/endpoints-v2-skeleton/build.gradle index e27f29b1747..7fa4d3edd88 100644 --- a/appengine-java8/endpoints-v2-skeleton/build.gradle +++ b/appengine-java8/endpoints-v2-skeleton/build.gradle @@ -38,7 +38,7 @@ apply plugin: 'com.google.cloud.tools.appengine' // [START dependencies] dependencies { - compile 'com.google.endpoints:endpoints-framework:2.0.8' + compile 'com.google.endpoints:endpoints-framework:2.0.9' compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59' compile 'javax.inject:javax.inject:1' diff --git a/appengine-java8/endpoints-v2-skeleton/pom.xml b/appengine-java8/endpoints-v2-skeleton/pom.xml index 5bc7ff2c262..7b61162d7e8 100644 --- a/appengine-java8/endpoints-v2-skeleton/pom.xml +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -85,7 +85,7 @@ com.google.cloud.tools appengine-maven-plugin - 1.3.1 + 1.3.2 @@ -96,7 +96,7 @@ 1.0.2 - YOUR-PROJECT-ID.appspot.com + YOUR_PROJECT_ID.appspot.com + java8 true @@ -26,3 +27,4 @@ + From 472b2f3b96ae6cb94850154c95d90d8c5abc9bd5 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 14 Nov 2017 10:34:30 -0800 Subject: [PATCH 06/10] Remove basic scaling --- .../src/main/webapp/WEB-INF/appengine-web.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml index 0deb18a4d34..03e9bfac4e9 100644 --- a/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml @@ -19,10 +19,6 @@ java8 true - - 2 - - From 0e4045eff3deffcb8885956bf1faaf0bb01696e0 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 14 Nov 2017 10:48:55 -0800 Subject: [PATCH 07/10] Add skeleton sample to parent pom --- appengine-java8/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/appengine-java8/pom.xml b/appengine-java8/pom.xml index 1eef6ab237b..acded09594a 100644 --- a/appengine-java8/pom.xml +++ b/appengine-java8/pom.xml @@ -48,6 +48,7 @@ endpoints-v2-backend endpoints-v2-migration endpoints-v2-guice + endpoints-v2-skeleton firebase-event-proxy From 83bb00b753f969e4e467d5ba0f687b1dfda5313a Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 14 Nov 2017 10:50:50 -0800 Subject: [PATCH 08/10] Add explicit instructions to update project id --- appengine-java8/endpoints-v2-skeleton/build.gradle | 1 + appengine-java8/endpoints-v2-skeleton/pom.xml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/appengine-java8/endpoints-v2-skeleton/build.gradle b/appengine-java8/endpoints-v2-skeleton/build.gradle index 7fa4d3edd88..bbecaa6c7b8 100644 --- a/appengine-java8/endpoints-v2-skeleton/build.gradle +++ b/appengine-java8/endpoints-v2-skeleton/build.gradle @@ -46,6 +46,7 @@ dependencies { } // [END dependencies] +// You must replace YOUR_PROJECT_ID with your Google Cloud Project Id def projectId = 'YOUR_PROJECT_ID' // [START endpoints_server_configuration] diff --git a/appengine-java8/endpoints-v2-skeleton/pom.xml b/appengine-java8/endpoints-v2-skeleton/pom.xml index 7b61162d7e8..c3817be3e56 100644 --- a/appengine-java8/endpoints-v2-skeleton/pom.xml +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -96,6 +96,10 @@ 1.0.2 + YOUR_PROJECT_ID.appspot.com From 5f80fa124dc26018fb873b9d590a179781d47db7 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 14 Nov 2017 10:57:56 -0800 Subject: [PATCH 09/10] Added more information into the MyApi.java class --- .../src/main/java/com/example/skeleton/MyApi.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java b/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java index eae8f5fb82a..e35c6f36a91 100644 --- a/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java +++ b/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java @@ -21,7 +21,15 @@ /** * MyApi skeleton endpoints sample * Add your first API methods in this class, or you may create another class. - * In that case, update your src/main/webapp/WEB-INF/web.xml accordingly. + * In that case, update the src/main/webapp/WEB-INF/web.xml and modify + * the class set to the services param as a comma separated list. + * + * For example: + * + * services + * com.example.skeleton.FirstApi, com.example.skeleton.SecondApi + * + * */ @Api(name = "skeleton-api", version = "v1") From 5ac283460f870f23e0fbb7583d364bc2be4fa2ab Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Tue, 14 Nov 2017 14:33:54 -0800 Subject: [PATCH 10/10] Remove versions plugin from pom.xml --- appengine-java8/endpoints-v2-skeleton/pom.xml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/appengine-java8/endpoints-v2-skeleton/pom.xml b/appengine-java8/endpoints-v2-skeleton/pom.xml index c3817be3e56..123b4031133 100644 --- a/appengine-java8/endpoints-v2-skeleton/pom.xml +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -103,24 +103,6 @@ YOUR_PROJECT_ID.appspot.com - - - org.codehaus.mojo - versions-maven-plugin - 2.3 - - - compile - - display-dependency-updates - display-plugin-updates - - - -