Skip to content

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

Merged
merged 23 commits into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
27fc125
Adding endpoints v1 using endpoints frameworks v2 samples
Jan 19, 2017
c997b45
Removing CONTRIB and LICENSE from within a sample
Jan 19, 2017
bf45639
Moved endpoints-v1-using-endpoints-frameworks-v2
Jan 27, 2017
9ed4fe1
Removed nbactions.xml and eclipse-launch-profiles.
Jan 27, 2017
4837310
Removed 'All Rights Reserved'
Jan 27, 2017
49dd01f
Added project id to expected test output in Jenkins.sh
Jan 27, 2017
3771154
Removed unnecessary plugins
Jan 30, 2017
6be18e5
Added README to explain the endpoints directories for Standard
Jan 30, 2017
0161bd1
Updated discovery doc sample for EP standard
Jan 30, 2017
447cd7a
Updating PROJECT_ID to VERSION_ID in Jenkins.sh test
Jan 31, 2017
42298a8
Making Endpoints E2E tests version specific.
Jan 31, 2017
9d6fe59
Typo... in which argument being used.
Jan 31, 2017
5600031
Adding Gradle tests to Jenkins.sh
Jan 31, 2017
ff0bb3b
Merge branch 'master' into add_endpoints_hello_sample
lesv Jan 31, 2017
ed02821
Changed README text for endpoints-frameworks-v2/
Jan 31, 2017
ec6b6ba
Updating endpoints-frameworks-v2/discovery/Jenkins.sh to be version s…
Jan 31, 2017
129988e
Merge branch 'add_endpoints_hello_sample' of github.com:GoogleCloudPl…
Jan 31, 2017
278313b
Added parent pom to pom.xml and updated sample based on stylecheck.
Jan 31, 2017
5771eab
fix typo. setting java compiler source and target
Jan 31, 2017
e8ceb34
Adding space between region tags
Jan 31, 2017
79ec9e1
Modified verbage for cost related to endpoints in README
Jan 31, 2017
ef7ab95
Updated endpionts README to give more information about user authenti…
Jan 31, 2017
67f2946
Double quotes for environment variables Jenkins.sh
Jan 31, 2017
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
41 changes: 41 additions & 0 deletions appengine/endpoints-v1-using-endpoints-frameworks-v2/Jenkins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
Copy link
Contributor

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.


# Copyright 2017 Google Inc. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The 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" | \
Copy link
Contributor

Choose a reason for hiding this comment

The 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."
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

88 changes: 88 additions & 0 deletions appengine/endpoints-v1-using-endpoints-frameworks-v2/README.md
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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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
67 changes: 67 additions & 0 deletions appengine/endpoints-v1-using-endpoints-frameworks-v2/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2017 Google Inc. All Rights Reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The 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"?>
Copy link
Contributor

Choose a reason for hiding this comment

The 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"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be Deploy? -- we may wish to drop this.

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Loading