diff --git a/endpoints-skeleton-archetype/pom.xml b/endpoints-skeleton-archetype/pom.xml index 77c116c..8a90dc9 100644 --- a/endpoints-skeleton-archetype/pom.xml +++ b/endpoints-skeleton-archetype/pom.xml @@ -1,6 +1,6 @@ + + + 1.0.0 + ${endpoints-p} + ${endpoints-fw} + 1 1.7 1.7 - true - true + 2.1 + UTF-8 + 2.5 @@ -29,52 +47,30 @@ + + + + - com.google.appengine - appengine-api-1.0-sdk - ${appengine.version} - - - com.google.appengine - appengine-endpoints - ${appengine.version} + com.google.endpoints + endpoints-framework + ${endpoints.framework.version} + javax.servlet servlet-api - 2.5 + ${servlet.api.version} provided javax.inject javax.inject - 1 - - - - - junit - junit - 4.12 - test - - - org.mockito - mockito-all - 2.0.2-beta - test - - - com.google.appengine - appengine-testing - ${appengine.version} - test - - - com.google.appengine - appengine-api-stubs - ${appengine.version} - test + ${javax.inject.version} @@ -83,65 +79,44 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes - org.codehaus.mojo - versions-maven-plugin - 2.1 + com.google.cloud.tools + appengine-maven-plugin + ${appengine.maven.version} + + + + + + com.google.cloud.tools + endpoints-framework-maven-plugin + ${endpoints.maven.plugin.version} + + src/main/webapp + ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF + - compile + generate-sources - display-dependency-updates - display-plugin-updates + discoveryDocs - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml - - - - ${project.build.directory}/generated-sources/appengine-endpoints - - - WEB-INF/*.discovery - WEB-INF/*.api - - - - - - - com.google.appengine - appengine-maven-plugin - ${appengine.version} - - false - ${app.version} - - - - - + org.codehaus.mojo + versions-maven-plugin + ${mojo.versions.maven.version} + compile - endpoints_get_discovery_doc + display-dependency-updates + display-plugin-updates - diff --git a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/Constants.java b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/Constants.java deleted file mode 100644 index d25ec4d..0000000 --- a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/Constants.java +++ /dev/null @@ -1,16 +0,0 @@ -#set( $symbol_pound = '#' ) -#set( $symbol_dollar = '$' ) -#set( $symbol_escape = '\' ) -package ${package}; - -/** - * Contains the client IDs and scopes for allowed clients consuming your API. - */ -public class Constants { - public static final String WEB_CLIENT_ID = "${web-client-id}"; - public static final String ANDROID_CLIENT_ID = "${android-client-id}"; - public static final String IOS_CLIENT_ID = "${ios-client-id}"; - public static final String ANDROID_AUDIENCE = WEB_CLIENT_ID; - - public static final String EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email"; -} diff --git a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/YourFirstAPI.java b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/YourFirstAPI.java index e474417..97a81cf 100644 --- a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/YourFirstAPI.java +++ b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/java/YourFirstAPI.java @@ -3,9 +3,13 @@ #set( $symbol_escape = '\' ) package ${package}; +import com.google.api.server.spi.config.Api; + /** * Add your first API methods in this class, or you may create another class. In that case, please * update your web.xml accordingly. **/ +@Api(name = "skeleton-api", + version = "v1") public class YourFirstAPI { } diff --git a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml index 1c95586..1e524d6 100644 --- a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml +++ b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml @@ -1,10 +1,5 @@ -#set( $symbol_pound = '#' ) -#set( $symbol_dollar = '$' ) -#set( $symbol_escape = '\' ) - ${app.id} - ${app.version} true diff --git a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml index 5d4f926..f217f0b 100644 --- a/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml +++ b/endpoints-skeleton-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -1,18 +1,53 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) - +#** +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. +*# + + + + + + EndpointsServlet + com.google.api.server.spi.EndpointsServlet + services ${package}.YourFirstAPI + + restricted + false + + + + + + EndpointsServlet + /_ah/api/* + index.html diff --git a/endpoints-skeleton-archetype/src/test/resources/projects/basic/archetype.properties b/endpoints-skeleton-archetype/src/test/resources/projects/basic/archetype.properties index 495bc4c..74918bc 100644 --- a/endpoints-skeleton-archetype/src/test/resources/projects/basic/archetype.properties +++ b/endpoints-skeleton-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,10 +1,7 @@ -#Tue May 06 16:04:48 PDT 2014 +# Tue Jan 31 11:39:16 PST 2017 package=it.pkg version=0.1-SNAPSHOT groupId=archetype.it artifactId=basic -appengine-version=1.9.38 -application-id=your-app-id -web-client-id=replace this with your web client ID -android-client-id=replace this with your Android client ID -ios-client-id=replace this with your iOS client ID +endpoints-fw=2.0.0-beta.12 +endpoints-p=1.0.0-beta2 diff --git a/hello-endpoints-archetype/Jenkins.sh b/hello-endpoints-archetype/Jenkins.sh new file mode 100644 index 0000000..ddb1ea1 --- /dev/null +++ b/hello-endpoints-archetype/Jenkins.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Fail on non-zero return and print +set -xe + +# Jenkins Test Script +function TestEndpoints () { + # Test getGreeting Endpoint (hello world!) + curl -X GET \ + "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \ + grep "hello version-${2}" + + # Test getGreeting Endpoint (goodbye world!) + curl -X GET \ + "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ + grep "goodbye world!" + + # Test listGreeting Endpoint (hello world! and goodbye world!) + curl -X GET \ + "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting" | \ + grep "hello world!\|goodbye world!" + + # Test multiply Endpoint (This is a greeting.) + curl -X POST \ + -H "Content-Type: application/json" \ + --data "{'message':'This is a greeting from instance ${2}'}." \ + "https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ + grep "This is a greeting from instance ${2}." +} + +# Build Test Archetype +mvn verify + +# Change path to generated archetype +pushd target/test-classes/projects/basic/project/basic + +# Jenkins provides values for GOOGLE_PROJECT_ID and GOOGLE_VERSION_ID +# Update Greetings.java +sed -i'.bak' -e "s/hello world!/hello version-${GOOGLE_VERSION_ID}!/g" src/main/java/it/pkg/Greetings.java + +# Attempt to clean and deploy generated archetype +mvn clean appengine:deploy \ + -Dapp.deploy.version="${GOOGLE_VERSION_ID}" + +# End-2-End tests +TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" + +# Clean +mvn clean + +# Set deploy version +sed -i'.bak' -e "s/deploy {/deploy {\n version='${GOOGLE_VERSION_ID}'/g" build.gradle + +# Modify Greetings.java for Gradle +sed -i'.bak' -e "s/hello version-${GOOGLE_VERSION_ID}!/hello version-gradle-${GOOGLE_VERSION_ID}!/g" src/main/java/it/pkg/Greetings.java + +# Deploy +gradle appengineDeploy + +# End-2-End tests +TestEndpoints "${GOOGLE_PROJECT_ID}" "gradle-${GOOGLE_VERSION_ID}" + +# Clean up +gradle clean + +# Pop from generated archetype +popd + + diff --git a/hello-endpoints-archetype/pom.xml b/hello-endpoints-archetype/pom.xml index 152bea5..7a8e3fa 100644 --- a/hello-endpoints-archetype/pom.xml +++ b/hello-endpoints-archetype/pom.xml @@ -1,6 +1,6 @@ + + + 1.0.0 + ${endpoints-p} + ${endpoints-fw} + 1 1.7 1.7 - true - true + 2.1 + UTF-8 + 2.5 @@ -27,57 +48,30 @@ + + + + - com.google.appengine - appengine-api-1.0-sdk - ${appengine.version} - - - com.google.appengine - appengine-endpoints - ${appengine.version} + com.google.endpoints + endpoints-framework + ${endpoints.framework.version} + javax.servlet servlet-api - 2.5 + ${servlet.api.version} provided javax.inject javax.inject - 1 - - - javax.jdo - jdo-api - 3.1 - - - - - junit - junit - 4.12 - test - - - org.mockito - mockito-all - 2.0.2-beta - test - - - com.google.appengine - appengine-testing - ${appengine.version} - test - - - com.google.appengine - appengine-api-stubs - ${appengine.version} - test + ${javax.inject.version} @@ -86,64 +80,44 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes - org.codehaus.mojo - versions-maven-plugin - 2.1 + com.google.cloud.tools + appengine-maven-plugin + ${appengine.maven.version} + + + + + + com.google.cloud.tools + endpoints-framework-maven-plugin + ${endpoints.maven.plugin.version} + + src/main/webapp + ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF + - compile + generate-sources - display-dependency-updates - display-plugin-updates + discoveryDocs - - - org.apache.maven.plugins - maven-war-plugin - 2.6 - - ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml - - - - ${project.build.directory}/generated-sources/appengine-endpoints - - - WEB-INF/*.discovery - WEB-INF/*.api - - - - - - com.google.appengine - appengine-maven-plugin - ${appengine.version} - - false - ${app.version} - - - - - + org.codehaus.mojo + versions-maven-plugin + ${mojo.versions.maven.version} + compile - endpoints_get_discovery_doc + display-dependency-updates + display-plugin-updates - diff --git a/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml b/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml index 1c95586..c5de05f 100644 --- a/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml +++ b/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/appengine-web.xml @@ -1,11 +1,6 @@ -#set( $symbol_pound = '#' ) -#set( $symbol_dollar = '$' ) -#set( $symbol_escape = '\' ) - ${app.id} - ${app.version} - true + true diff --git a/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml index 89fa067..bebf56a 100644 --- a/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml +++ b/hello-endpoints-archetype/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -1,18 +1,53 @@ #set( $symbol_pound = '#' ) #set( $symbol_dollar = '$' ) #set( $symbol_escape = '\' ) - +#** +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. +*# + + + + + + EndpointsServlet + com.google.api.server.spi.EndpointsServlet + services ${package}.Greetings + + restricted + false + + + + + + EndpointsServlet + /_ah/api/* + index.html diff --git a/hello-endpoints-archetype/src/test/resources/projects/basic/archetype.properties b/hello-endpoints-archetype/src/test/resources/projects/basic/archetype.properties index 495bc4c..55e3db8 100644 --- a/hello-endpoints-archetype/src/test/resources/projects/basic/archetype.properties +++ b/hello-endpoints-archetype/src/test/resources/projects/basic/archetype.properties @@ -1,10 +1,10 @@ -#Tue May 06 16:04:48 PDT 2014 +#Tue January 17 11:54:00 PDT 2017 package=it.pkg version=0.1-SNAPSHOT groupId=archetype.it artifactId=basic -appengine-version=1.9.38 -application-id=your-app-id +endpoints-fw=2.0.0-beta.12 +endpoints-p=1.0.0-beta2 web-client-id=replace this with your web client ID android-client-id=replace this with your Android client ID ios-client-id=replace this with your iOS client ID