Skip to content

Commit 204b5fb

Browse files
authored
Add Frameworks Samples (GoogleCloudPlatform#1411)
* micronaut helloworld sample * Update readmes * Add ktor sample * Add Quarkus sample * Add vertx sample * Add Framework samples * Add annotation * Update endpoint * Update Micronaut tests * Update appengine plugin version * Add license * Respond to PR comments * update spark imports * micronaut styling * More styling updates * Rollback plugin version
1 parent 3656dad commit 204b5fb

File tree

40 files changed

+1536
-8
lines changed

40 files changed

+1536
-8
lines changed

appengine-java11/gaeinfo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Copyright 2019 Google LLC
124124
<plugin>
125125
<groupId>com.google.cloud.tools</groupId>
126126
<artifactId>appengine-maven-plugin</artifactId>
127-
<version>2.0.0-rc5</version>
127+
<version>2.0.0-rc6</version>
128128
<configuration>
129129
<version>gaeinfo</version>
130130
</configuration>

appengine-java11/guestbook-cloud-firestore/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<plugin>
8181
<groupId>com.google.cloud.tools</groupId>
8282
<artifactId>appengine-maven-plugin</artifactId>
83-
<version>2.0.0-rc5</version>
83+
<version>2.0.0-rc6</version>
8484
<configuration>
8585
<version>guestbook</version>
8686
</configuration>

appengine-java11/http-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<plugin>
3838
<groupId>com.google.cloud.tools</groupId>
3939
<artifactId>appengine-maven-plugin</artifactId>
40-
<version>2.0.0-rc5</version>
40+
<version>2.0.0-rc6</version>
4141
<configuration>
4242
<version>http-server</version>
4343
</configuration>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Ktor Application on Google App Engine Standard with Kotlin
2+
3+
This sample shows how to deploy a [Ktor](https://ktor.io/)
4+
application to Google App Engine standard.
5+
6+
## Setup
7+
8+
See [Prerequisites](../README.md#Prerequisites).
9+
10+
## Deploying
11+
12+
```bash
13+
mvn clean package appengine:deploy -Dapp.deploy.projectId=<your-project-id>
14+
```
15+
16+
To view your app, use command:
17+
```
18+
gcloud app browse
19+
```
20+
Or navigate to http://<project-id>.appspot.com URL.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
runtime: java11
16+
instance_class: F2
17+
entrypoint: 'java -Xmx32m -jar kotlin-ktor-0.0.1-jar-with-dependencies.jar'
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2019 Google LLC
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+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
18+
<modelVersion>4.0.0</modelVersion>
19+
<groupId>com.example.appengine</groupId>
20+
<artifactId>kotlin-ktor</artifactId>
21+
<version>0.0.1</version>
22+
23+
<!--
24+
The parent pom defines common style checks and testing strategies for our samples.
25+
Removing or replacing it should not affect the execution of the samples in anyway.
26+
-->
27+
<parent>
28+
<groupId>com.google.cloud.samples</groupId>
29+
<artifactId>shared-configuration</artifactId>
30+
<version>1.0.11</version>
31+
</parent>
32+
33+
<properties>
34+
<kotlin.code.style>official</kotlin.code.style>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
37+
<main.class>io.ktor.server.netty.EngineMain</main.class>
38+
<maven.compiler.target>11</maven.compiler.target>
39+
<maven.compiler.source>11</maven.compiler.source>
40+
</properties>
41+
42+
<repositories>
43+
<repository>
44+
<id>repo1</id>
45+
<url>https://jcenter.bintray.com</url>
46+
<releases><enabled>true</enabled></releases>
47+
<snapshots><enabled>true</enabled></snapshots>
48+
</repository>
49+
<repository>
50+
<id>repo2</id>
51+
<url>https://kotlin.bintray.com/ktor</url>
52+
<releases><enabled>true</enabled></releases>
53+
<snapshots><enabled>true</enabled></snapshots>
54+
</repository>
55+
</repositories>
56+
57+
<dependencies>
58+
<dependency>
59+
<groupId>org.jetbrains.kotlin</groupId>
60+
<artifactId>kotlin-stdlib-jdk8</artifactId>
61+
<version>1.3.30</version>
62+
</dependency>
63+
<dependency>
64+
<groupId>io.ktor</groupId>
65+
<artifactId>ktor-server-netty</artifactId>
66+
<version>1.1.3</version>
67+
</dependency>
68+
<dependency>
69+
<groupId>ch.qos.logback</groupId>
70+
<artifactId>logback-classic</artifactId>
71+
<version>1.2.3</version>
72+
</dependency>
73+
<dependency>
74+
<groupId>io.ktor</groupId>
75+
<artifactId>ktor-server-core</artifactId>
76+
<version>1.1.3</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>io.ktor</groupId>
80+
<artifactId>ktor-server-host-common</artifactId>
81+
<version>1.1.3</version>
82+
</dependency>
83+
<dependency>
84+
<groupId>io.ktor</groupId>
85+
<artifactId>ktor-server-tests</artifactId>
86+
<version>1.1.3</version>
87+
<scope>test</scope>
88+
</dependency>
89+
</dependencies>
90+
91+
<build>
92+
<sourceDirectory>${project.basedir}/src</sourceDirectory>
93+
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
94+
<resources>
95+
<resource>
96+
<directory>${project.basedir}/resources</directory>
97+
</resource>
98+
</resources>
99+
<plugins>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-surefire-plugin</artifactId>
103+
</plugin>
104+
<plugin>
105+
<artifactId>maven-compiler-plugin</artifactId>
106+
<configuration><source>1.8</source><target>1.8</target></configuration>
107+
</plugin>
108+
<plugin>
109+
<artifactId>kotlin-maven-plugin</artifactId>
110+
<groupId>org.jetbrains.kotlin</groupId>
111+
<version>1.3.30</version>
112+
<executions>
113+
<execution>
114+
<id>compile</id>
115+
<goals><goal>compile</goal></goals>
116+
<configuration>
117+
<experimentalCoroutines>enable</experimentalCoroutines>
118+
</configuration>
119+
</execution>
120+
<execution>
121+
<id>test-compile</id>
122+
<goals><goal>test-compile</goal></goals>
123+
<configuration>
124+
<experimentalCoroutines>enable</experimentalCoroutines>
125+
</configuration>
126+
</execution>
127+
</executions>
128+
</plugin>
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-jar-plugin</artifactId>
132+
<version>2.6</version>
133+
<configuration>
134+
<archive>
135+
<manifest>
136+
<addClasspath>true</addClasspath>
137+
<mainClass>${main.class}</mainClass>
138+
</manifest>
139+
</archive>
140+
</configuration>
141+
</plugin>
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-assembly-plugin</artifactId>
145+
<version>2.6</version>
146+
<executions>
147+
<execution>
148+
<id>make-assembly</id>
149+
<phase>package</phase>
150+
<goals> <goal>single</goal> </goals>
151+
<configuration>
152+
<archive>
153+
<manifest>
154+
<mainClass>${main.class}</mainClass>
155+
</manifest>
156+
</archive>
157+
<descriptorRefs>
158+
<descriptorRef>jar-with-dependencies</descriptorRef>
159+
</descriptorRefs>
160+
</configuration>
161+
</execution>
162+
</executions>
163+
</plugin>
164+
<!-- Add App Engine plugin -->
165+
<plugin>
166+
<groupId>com.google.cloud.tools</groupId>
167+
<artifactId>appengine-maven-plugin</artifactId>
168+
<version>2.0.0-rc6</version>
169+
<configuration>
170+
<version>kotlin-ktor</version>
171+
<!-- Ktor generator moved from Maven convention of src/main/* to simply th top level project directory -->
172+
<appEngineDirectory>./</appEngineDirectory>
173+
<!-- Tell App Engine plugin to use the Fat JAR with all of the dependencies -->
174+
<artifact>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar</artifact>
175+
</configuration>
176+
</plugin>
177+
</plugins>
178+
</build>
179+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ktor {
16+
deployment {
17+
port = 8080
18+
port = ${?PORT}
19+
20+
shutdown.url = "/_ah/stop"
21+
}
22+
application {
23+
modules = [ com.example.appengine.ApplicationKt.module ]
24+
}
25+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!--
2+
Copyright 2019 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<configuration>
18+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
19+
<encoder>
20+
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
21+
</encoder>
22+
</appender>
23+
<root level="trace">
24+
<appender-ref ref="STDOUT"/>
25+
</root>
26+
<logger name="org.eclipse.jetty" level="INFO"/>
27+
<logger name="io.netty" level="INFO"/>
28+
</configuration>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.example.appengine
16+
17+
import io.ktor.application.*
18+
import io.ktor.response.*
19+
import io.ktor.request.*
20+
import io.ktor.routing.*
21+
import io.ktor.http.*
22+
import io.ktor.content.*
23+
import io.ktor.http.content.*
24+
import io.ktor.server.engine.*
25+
26+
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
27+
28+
@Suppress("unused") // Referenced in application.conf
29+
@kotlin.jvm.JvmOverloads
30+
fun Application.module(testing: Boolean = false) {
31+
install(ShutDownUrl.ApplicationCallFeature) {
32+
// The URL that will be intercepted. You can also use the
33+
// application.conf's ktor.deployment.shutdown.url key.
34+
shutDownUrl = "/_ah/stop"
35+
36+
// A function that will be executed to get the exit code of the process
37+
exitCodeSupplier = { 0 } // ApplicationCall.() -> Int
38+
}
39+
40+
routing {
41+
get("/") {
42+
call.respondText("Hello World!", contentType = ContentType.Text.Plain)
43+
}
44+
}
45+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.example.appengine
16+
17+
import io.ktor.application.*
18+
import io.ktor.response.*
19+
import io.ktor.request.*
20+
import io.ktor.routing.*
21+
import io.ktor.http.*
22+
import io.ktor.content.*
23+
import io.ktor.http.content.*
24+
import io.ktor.server.engine.*
25+
import kotlin.test.*
26+
import io.ktor.server.testing.*
27+
28+
class ApplicationTest {
29+
@Test
30+
fun testRoot() {
31+
withTestApplication({ module(testing = true) }) {
32+
handleRequest(HttpMethod.Get, "/").apply {
33+
assertEquals(HttpStatusCode.OK, response.status())
34+
assertEquals("Hello World!", response.content)
35+
}
36+
}
37+
}
38+
}

0 commit comments

Comments
 (0)