diff --git a/appengine-java8/endpoints-v2-skeleton/README.md b/appengine-java8/endpoints-v2-skeleton/README.md new file mode 100644 index 00000000000..deb996b5910 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/README.md @@ -0,0 +1,7 @@ +# App Engine Standard & Endpoints Frameworks skeleton + +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..bbecaa6c7b8 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/build.gradle @@ -0,0 +1,85 @@ +// 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.9' + 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] + +// You must replace YOUR_PROJECT_ID with your Google Cloud Project Id +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..123b4031133 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/pom.xml @@ -0,0 +1,110 @@ + + + 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.2 + + + + + + com.google.cloud.tools + endpoints-framework-maven-plugin + 1.0.2 + + + + YOUR_PROJECT_ID.appspot.com + + + + + + + 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..e35c6f36a91 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/java/com/example/skeleton/MyApi.java @@ -0,0 +1,38 @@ +/* + * 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 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") +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..03e9bfac4e9 --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,26 @@ + + + + + java8 + true + + + + + + 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..1966288424f --- /dev/null +++ b/appengine-java8/endpoints-v2-skeleton/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,38 @@ + + + + + + + EndpointsServlet + com.google.api.server.spi.EndpointsServlet + + services + com.example.skeleton.MyApi + + + + + EndpointsServlet + /_ah/api/* + + + 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