-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Move and update appengine-endpoints-helloendpoints-java-maven sample #488
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
Changes from 2 commits
27fc125
c997b45
bf45639
9ed4fe1
4837310
49dd01f
3771154
6be18e5
0161bd1
447cd7a
42298a8
9d6fe59
5600031
ff0bb3b
ed02821
ec6b6ba
129988e
278313b
5771eab
e8ceb34
79ec9e1
ef7ab95
67f2946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2017 Google Inc. All Rights Reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use: All Rights Reserved. |
||
# | ||
# 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. | ||
|
||
# Fail on non-zero return and print command to stdout | ||
set -xe | ||
|
||
# Jenkins Test Script | ||
# Test getGreeting Endpoint (hello world!) | ||
curl -X GET \ | ||
"https://${GOOGLE_PROJECT_ID}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know this is set? |
||
grep "hello world!" | ||
|
||
# Test getGreeting Endpoint (goodbye world!) | ||
curl -X GET \ | ||
"https://${GOOGLE_PROJECT_ID}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ | ||
grep "goodbye world!" | ||
|
||
# Test listGreeting Endpoint (hello world! and goodbye world!) | ||
curl -X GET \ | ||
"https://${GOOGLE_PROJECT_ID}.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.'}" \ | ||
"https://${GOOGLE_PROJECT_ID}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \ | ||
grep "This is a greeting." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you do to make sure you aren't looking at greetings from earlier runs? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Hello World Cloud Endpoints v1.0 using Endpoints Frameworks v2.0 | ||
|
||
This is an example of a [migrated][7] Cloud Endpoints v1.0 application using | ||
Endpoints Frameworks v2.0. If you're not ready to migrate your application, | ||
this example also provides information of how to use Endponts Frameworks v2.0 Maven | ||
and Gradle discovery and client library generation plugins with existing | ||
Endpoints Frameworks v1.0 projects. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might wish to mention that the plugins are based on the 'newer cloud SDK' not the older 'java sdk'. |
||
|
||
# Hello World using Cloud Endpoints v1.0 Application | ||
|
||
A "hello world" application for Google Cloud Endpoints in Java. | ||
|
||
## Products | ||
- [App Engine][1] | ||
|
||
## Language | ||
- [Java][2] | ||
|
||
## APIs | ||
- [Google Cloud Endpoints][3] | ||
- [Google App Engine Maven plugin][4] | ||
|
||
## Setup Instructions | ||
1. [Optional]: These sub steps are not required but will enable the "Authenticated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice. |
||
Greeting" functionality. | ||
|
||
1. Update the values in [src/main/java/com/example/helloendpoints/Constants.java](src/main/java/com/example/helloendpoints/Constants.java) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could just say Constants.java, with the link. |
||
to reflect the web client ID you have registered in the [Credentials on Developers Console for OAuth 2.0 client IDs][6]. | ||
|
||
1. Update the value of `google.devrel.samples.helloendpoints.CLIENT_ID` in | ||
[src/main/webapp/js/base.js](src/main/webapp/js/base.js) to reflect the web client ID you have registered in the | ||
[Credentials on Developers Console for OAuth 2.0 client IDs][6]. | ||
|
||
1. [Optional]: Use Endpoints Frameworks v2.0 Maven and Gradle disovery and | ||
client library generation plugins with Endpoints Frameworks v1.0. | ||
|
||
* Uncomment commented Endpoints Frameworks v1.0 sections and comment | ||
Endpoints Frameworks v2.0 sections in the following files. | ||
|
||
``` | ||
pom.xml | ||
build.gradle | ||
src/main/webapp/WEB-INF/web.xml | ||
``` | ||
|
||
### Maven | ||
|
||
1. Build a fresh binary with | ||
|
||
`mvn clean compile` | ||
|
||
1. Run the application locally at [localhost:8080][5] with | ||
|
||
`mvn appengine:run` | ||
|
||
1. Generate the client library in a zip file named `helloworld-v1-java.zip` with | ||
|
||
`mvn endpoints-framework:clientLibs` | ||
|
||
1. Deploy your application to Google App Engine with | ||
|
||
`mvn appengine:deploy` | ||
|
||
### Gradle | ||
|
||
1. Build a fresh binary with | ||
|
||
`gradle clean compileJava` | ||
|
||
1. Run the application locally at [localhost:8080][5] with | ||
|
||
`gradle appengineRun` | ||
|
||
1. Generate the client library in a zip file named `helloworld-v1-java.zip` with | ||
|
||
`gradle endpointsClientLibs` | ||
|
||
1. Deploy your application to Google App Engine with | ||
|
||
`gradle appengineDeploy` | ||
|
||
[1]: https://developers.google.com/appengine | ||
[2]: http://java.com/en/ | ||
[3]: https://developers.google.com/appengine/docs/java/endpoints/ | ||
[4]: https://developers.google.com/appengine/docs/java/tools/maven | ||
[5]: https://localhost:8080/ | ||
[6]: https://console.developers.google.com/project/_/apiui/credential | ||
[7]: https://cloud.google.com/appengine/docs/java/endpoints/migrating |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2017 Google Inc. All Rights Reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strike All Rights Reserved. |
||
// | ||
// 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. | ||
|
||
buildscript { // Configuration for building | ||
repositories { | ||
mavenCentral() | ||
jcenter() // Bintray's repository - a fast Maven Central mirror & more | ||
} | ||
dependencies { | ||
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+' // latest App Engine Gradle tasks | ||
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+' | ||
} | ||
} | ||
|
||
repositories { // repositories for Jar's you access in your code | ||
maven { | ||
url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT Repository (if needed) | ||
} | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
apply plugin: 'java' // standard Java tasks | ||
apply plugin: 'war' // standard Web Archive plugin | ||
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks | ||
apply plugin: 'com.google.cloud.tools.endpoints-framework-server' | ||
|
||
dependencies { | ||
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5' | ||
compile 'jstl:jstl:1.2' | ||
compile group: 'javax.inject', name: 'javax.inject', version: '1' | ||
|
||
// Uncomment to use Endpoints Frameworks v1.0 | ||
// compile group: 'com.google.appengine', name: 'appengine-endpoints', version: '1.9.48' | ||
// End of Endpoints Frameworks v1.0 | ||
|
||
// Endpoints Frameworks v2.0 | ||
compile "com.google.endpoints:endpoints-framework:+" | ||
// End of Endpoints Frameworks v2.0 | ||
} | ||
|
||
appengine { // App Engine tasks configuration | ||
run { // local (dev_appserver) configuration (standard environments only) | ||
|
||
} | ||
|
||
deploy { // deploy configuration | ||
|
||
} | ||
} | ||
|
||
group = "com.example.helloendpoints" // Generated output GroupId | ||
version = "1" // Version in generated output | ||
|
||
sourceCompatibility = 1.7 // App Engine Standard uses Java 7 | ||
targetCompatibility = 1.7 // App Engine Standard uses Java 7 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may wish to drop this, if not, it should have a copyright. |
||
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType"> | ||
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/> | ||
<stringAttribute key="M2_GOALS" value="appengine:run"/> | ||
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/> | ||
<booleanAttribute key="M2_OFFLINE" value="false"/> | ||
<stringAttribute key="M2_PROFILES" value=""/> | ||
<listAttribute key="M2_PROPERTIES"/> | ||
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/> | ||
<booleanAttribute key="M2_SKIP_TESTS" value="false"/> | ||
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/> | ||
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}"/> | ||
</launchConfiguration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be Deploy? -- we may wish to drop this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copyright if you keep. |
||
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType"> | ||
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/> | ||
<stringAttribute key="M2_GOALS" value="appengine:deploy"/> | ||
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/> | ||
<booleanAttribute key="M2_OFFLINE" value="false"/> | ||
<stringAttribute key="M2_PROFILES" value=""/> | ||
<listAttribute key="M2_PROPERTIES"/> | ||
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/> | ||
<booleanAttribute key="M2_SKIP_TESTS" value="false"/> | ||
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/> | ||
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}"/> | ||
</launchConfiguration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Mon Jan 16 22:18:59 PST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow - what a long path
endpoints-v1-using-endpoints-frameworks-v2
. Seems quite wordy, but Ok if you don't want to use abbreviations.