Skip to content

Commit a874897

Browse files
authored
Merge pull request #842 from GoogleCloudPlatform/endpoints-update
[Endpoints] Update/Add samples with new tooling and Guice support for v2
2 parents 090a336 + f69fbec commit a874897

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2510
-166
lines changed

appengine-java8/endpoints-v2-backend/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ To build the project:
3333

3434
To generate the required configuration file `openapi.json`:
3535

36-
mvn exec:java -DGetSwaggerDoc
36+
mvn endpoints-framework:openApiDocs
3737

3838
### Deploying the sample API to App Engine
3939

4040
To deploy the sample API:
4141

4242
0. Invoke the `gcloud` command to deploy the API configuration file:
4343

44-
gcloud service-management deploy openapi.json
44+
gcloud service-management deploy target/openapi-docs/openapi.json
4545

4646
0. Deploy the API implementation code by invoking:
4747

appengine-java8/endpoints-v2-backend/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ endpointsServer {
5454
hostname = "${projectId}.appspot.com"
5555
}
5656

57+
appengine { // App Engine tasks configuration
58+
deploy { // deploy configuration
59+
version = findProperty("appengine.deploy.version")
60+
61+
def promoteProp = findProperty("appengine.deploy.promote")
62+
if (promoteProp != null) {
63+
promote = new Boolean(promoteProp)
64+
}
65+
}
66+
}
67+
5768
sourceCompatibility = 1.8
5869
targetCompatibility = 1.8
5970

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Fail on non-zero return and print command to stdout
18+
set -xe
19+
20+
# Jenkins Test Script
21+
function TestEndpoints () {
22+
# Test getGreeting Endpoint (hello world!)
23+
curl -H "Content-Type: application/json" \
24+
-X POST \
25+
-d "{'message':'hello ${3} version-${2}'}" \
26+
"https://${2}-dot-${1}.appspot.com/_ah/api/echo/v1/echo" | \
27+
tee "$ERROR_OUTPUT_DIR/response.json" | \
28+
grep "hello ${3} version-${2}"
29+
}
30+
31+
# Jenkins provides values for GOOGLE_PROJECT_ID and GOOGLE_VERSION_ID
32+
# Update Greetings.java
33+
UNIQUE_MAVEN_STRING="maven"
34+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" pom.xml
35+
36+
mvn clean endpoints-framework:openApiDocs
37+
38+
gcloud service-management deploy target/openapi-docs/openapi.json
39+
40+
# Test with Maven
41+
mvn appengine:deploy \
42+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
43+
-Dapp.deploy.promote=false
44+
45+
# End-2-End tests
46+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_MAVEN_STRING}"
47+
48+
# Clean
49+
mvn clean
50+
51+
# Test with Gradle
52+
# Modify Greetings.java for Gradle
53+
UNIQUE_GRADLE_STRING="gradle"
54+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" build.gradle
55+
56+
gradle clean endpointsOpenApiDocs
57+
58+
gcloud service-management deploy build/endpointsOpenApiDocs/openapi.json
59+
60+
# Deploy Gradle
61+
gradle -Pappengine.deploy.promote=false \
62+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
63+
appengineDeploy
64+
65+
# End-2-End tests
66+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_GRADLE_STRING}"
67+
68+
# Clean
69+
gradle clean

appengine-java8/endpoints-v2-backend/pom.xml

Lines changed: 99 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -14,120 +14,112 @@
1414
limitations under the License.
1515
-->
1616
<project>
17-
<modelVersion>4.0.0</modelVersion>
18-
<packaging>war</packaging>
19-
<version>1.0-SNAPSHOT</version>
17+
<modelVersion>4.0.0</modelVersion>
18+
<packaging>war</packaging>
19+
<version>1.0-SNAPSHOT</version>
2020

21-
<groupId>com.example.echo</groupId>
22-
<artifactId>echo-j8</artifactId>
21+
<groupId>com.example.echo</groupId>
22+
<artifactId>echo-j8</artifactId>
2323

24-
<parent>
25-
<artifactId>appengine-java8-samples</artifactId>
26-
<groupId>com.google.cloud</groupId>
27-
<version>1.0.0</version>
28-
<relativePath>..</relativePath>
29-
</parent>
24+
<parent>
25+
<artifactId>appengine-java8-samples</artifactId>
26+
<groupId>com.google.cloud</groupId>
27+
<version>1.0.0</version>
28+
<relativePath>..</relativePath>
29+
</parent>
3030

31-
<properties>
32-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31+
<properties>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333

34-
<endpoints.framework.version>2.0.7</endpoints.framework.version>
35-
<endpoints.management.version>1.0.4</endpoints.management.version>
34+
<endpoints.framework.version>2.0.7</endpoints.framework.version>
35+
<endpoints.management.version>1.0.4</endpoints.management.version>
3636

37-
<endpoints.project.id>YOUR_PROJECT_ID</endpoints.project.id>
38-
<maven.compiler.target>1.8</maven.compiler.target>
39-
<maven.compiler.source>1.8</maven.compiler.source>
40-
<appengine.maven.plugin>1.3.1</appengine.maven.plugin>
41-
</properties>
37+
<endpoints.project.id>YOUR_PROJECT_ID</endpoints.project.id>
38+
<maven.compiler.target>1.8</maven.compiler.target>
39+
<maven.compiler.source>1.8</maven.compiler.source>
40+
<appengine.maven.plugin.version>1.3.1</appengine.maven.plugin.version>
41+
</properties>
4242

43-
<dependencies>
44-
<!-- Compile/runtime dependencies -->
45-
<dependency>
46-
<groupId>javax.servlet</groupId>
47-
<artifactId>javax.servlet-api</artifactId>
48-
<version>3.1.0</version>
49-
<type>jar</type>
50-
<scope>provided</scope>
51-
</dependency>
43+
<dependencies>
44+
<!-- Compile/runtime dependencies -->
45+
<dependency>
46+
<groupId>com.google.endpoints</groupId>
47+
<artifactId>endpoints-framework</artifactId>
48+
<version>${endpoints.framework.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.google.endpoints</groupId>
52+
<artifactId>endpoints-management-control-appengine-all</artifactId>
53+
<version>1.0.4</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>com.google.appengine</groupId>
57+
<artifactId>appengine-api-1.0-sdk</artifactId>
58+
<version>1.9.54</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>javax.servlet</groupId>
62+
<artifactId>javax.servlet-api</artifactId>
63+
<version>3.1.0</version>
64+
<type>jar</type>
65+
<scope>provided</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>javax.inject</groupId>
69+
<artifactId>javax.inject</artifactId>
70+
<version>1</version>
71+
</dependency>
72+
</dependencies>
5273

53-
<dependency>
54-
<groupId>com.google.endpoints</groupId>
55-
<artifactId>endpoints-framework</artifactId>
56-
<version>${endpoints.framework.version}</version>
57-
</dependency>
58-
<dependency>
59-
<groupId>com.google.endpoints</groupId>
60-
<artifactId>endpoints-management-control-appengine-all</artifactId>
61-
<version>${endpoints.management.version}</version>
62-
</dependency>
63-
</dependencies>
64-
65-
<profiles>
66-
<profile>
67-
<id>GetSwaggerDoc</id>
68-
<activation>
69-
<property>
70-
<name>GetSwaggerDoc</name>
71-
</property>
72-
</activation>
73-
<build>
74+
<build>
75+
<!-- for hot reload of the web application-->
76+
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
7477
<plugins>
75-
<plugin>
76-
<groupId>org.codehaus.mojo</groupId>
77-
<artifactId>exec-maven-plugin</artifactId>
78-
<version>1.4.0</version>
79-
<configuration>
80-
<includePluginDependencies>true</includePluginDependencies>
81-
<mainClass>com.google.api.server.spi.tools.EndpointsTool</mainClass>
82-
<arguments>
83-
<argument>get-swagger-doc</argument>
84-
<argument>--hostname=${endpoints.project.id}.appspot.com</argument>
85-
<argument>--war=target/echo-1.0-SNAPSHOT</argument>
86-
<argument>com.example.echo.Echo</argument>
87-
</arguments>
88-
</configuration>
89-
<dependencies>
90-
<dependency>
91-
<groupId>com.google.endpoints</groupId>
92-
<artifactId>endpoints-framework-tools</artifactId>
93-
<version>${endpoints.framework.version}</version>
94-
</dependency>
95-
<dependency>
96-
<groupId>com.google.appengine</groupId>
97-
<artifactId>appengine-api-1.0-sdk</artifactId>
98-
<version>1.9.52</version>
99-
</dependency>
100-
</dependencies>
101-
</plugin>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-war-plugin</artifactId>
81+
<version>2.6</version>
82+
<configuration>
83+
<webResources>
84+
<resources>
85+
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
86+
<filtering>true</filtering>
87+
<targetPath>WEB-INF</targetPath>
88+
</resources>
89+
</webResources>
90+
</configuration>
91+
</plugin>
92+
<plugin>
93+
<groupId>com.google.cloud.tools</groupId>
94+
<artifactId>appengine-maven-plugin</artifactId>
95+
<version>${appengine.maven.plugin.version}</version>
96+
<configuration>
97+
<!-- deploy configuration -->
98+
</configuration>
99+
</plugin>
100+
<plugin>
101+
<groupId>com.google.cloud.tools</groupId>
102+
<artifactId>endpoints-framework-maven-plugin</artifactId>
103+
<version>1.0.0</version>
104+
<configuration>
105+
<!-- plugin configuration -->
106+
<hostname>${endpoints.project.id}.appspot.com</hostname>
107+
</configuration>
108+
</plugin>
109+
<plugin>
110+
<groupId>org.codehaus.mojo</groupId>
111+
<artifactId>versions-maven-plugin</artifactId>
112+
<version>2.3</version>
113+
<executions>
114+
<execution>
115+
<phase>compile</phase>
116+
<goals>
117+
<goal>display-dependency-updates</goal>
118+
<goal>display-plugin-updates</goal>
119+
</goals>
120+
</execution>
121+
</executions>
122+
</plugin>
102123
</plugins>
103-
</build>
104-
</profile>
105-
</profiles>
106-
107-
<build>
108-
<!-- for hot reload of the web application-->
109-
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
110-
<plugins>
111-
<plugin>
112-
<groupId>org.apache.maven.plugins</groupId>
113-
<artifactId>maven-war-plugin</artifactId>
114-
<version>2.6</version>
115-
<configuration>
116-
<webResources>
117-
<resource>
118-
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
119-
<filtering>true</filtering>
120-
<targetPath>WEB-INF</targetPath>
121-
</resource>
122-
</webResources>
123-
</configuration>
124-
</plugin>
125-
126-
<plugin>
127-
<groupId>com.google.cloud.tools</groupId>
128-
<artifactId>appengine-maven-plugin</artifactId>
129-
<version>${appengine.maven.plugin}</version>
130-
</plugin>
131-
</plugins>
132-
</build>
124+
</build>
133125
</project>

0 commit comments

Comments
 (0)