Skip to content

Commit 97fd550

Browse files
committed
feat: add flexible samples
1 parent 39962cb commit 97fd550

File tree

22 files changed

+1371
-0
lines changed

22 files changed

+1371
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Micronaut Application on Google App Engine Flex with Java 25
2+
3+
This sample shows how to deploy a [Micronaut](https://micronaut.io/)
4+
application to Google App Engine Flex.
5+
6+
## Deploying
7+
8+
```bash
9+
gcloud app deploy
10+
```
11+
12+
To view your app, use command:
13+
```
14+
gcloud app browse
15+
```
16+
Or navigate to `https://<your-project-id>.appspot.com`.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2023 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+
profile: service
16+
defaultPackage: com.example.appengine
17+
---
18+
testFramework: junit
19+
sourceLanguage: java
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2023 Google LLC
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+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
-->
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
16+
<modelVersion>4.0.0</modelVersion>
17+
<groupId>com.example.appengine.flexible</groupId>
18+
<artifactId>micronaut-helloworld</artifactId>
19+
<version>0.1</version>
20+
21+
<!--
22+
The parent pom defines common style checks and testing strategies for our samples.
23+
Removing or replacing it should not affect the execution of the samples in anyway.
24+
-->
25+
<parent>
26+
<groupId>com.google.cloud.samples</groupId>
27+
<artifactId>shared-configuration</artifactId>
28+
<version>1.2.0</version>
29+
</parent>
30+
31+
<properties>
32+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
33+
<exec.mainClass>com.example.appengine.Application</exec.mainClass>
34+
<maven.compiler.target>21</maven.compiler.target>
35+
<maven.compiler.source>21</maven.compiler.source>
36+
<micronaut.version>3.10.3</micronaut.version>
37+
</properties>
38+
39+
<dependencies>
40+
<dependency>
41+
<groupId>io.micronaut</groupId>
42+
<artifactId>micronaut-inject</artifactId>
43+
<version>${micronaut.version}</version>
44+
<scope>compile</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.micronaut</groupId>
48+
<artifactId>micronaut-validation</artifactId>
49+
<version>${micronaut.version}</version>
50+
<scope>compile</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>io.micronaut</groupId>
54+
<artifactId>micronaut-runtime</artifactId>
55+
<version>${micronaut.version}</version>
56+
<scope>compile</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>io.micronaut</groupId>
60+
<artifactId>micronaut-http-client</artifactId>
61+
<version>${micronaut.version}</version>
62+
<scope>compile</scope>
63+
</dependency>
64+
<dependency>
65+
<groupId>javax.annotation</groupId>
66+
<artifactId>javax.annotation-api</artifactId>
67+
<version>1.3.2</version>
68+
<scope>compile</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>io.micronaut</groupId>
72+
<artifactId>micronaut-http-server-netty</artifactId>
73+
<version>${micronaut.version}</version>
74+
<scope>compile</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>junit</groupId>
78+
<artifactId>junit</artifactId>
79+
<version>4.13.2</version>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>com.google.cloud.tools</groupId>
88+
<artifactId>appengine-maven-plugin</artifactId>
89+
<version>2.8.0</version>
90+
<configuration>
91+
<projectId>GCLOUD_CONFIG</projectId>
92+
<version>micronaut-helloworld</version>
93+
</configuration>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-shade-plugin</artifactId>
98+
<version>3.5.1</version>
99+
<executions>
100+
<execution>
101+
<phase>package</phase>
102+
<goals>
103+
<goal>shade</goal>
104+
</goals>
105+
<configuration>
106+
<transformers>
107+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
108+
<mainClass>${exec.mainClass}</mainClass>
109+
</transformer>
110+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
111+
</transformers>
112+
</configuration>
113+
</execution>
114+
</executions>
115+
</plugin>
116+
<plugin>
117+
<groupId>org.codehaus.mojo</groupId>
118+
<artifactId>exec-maven-plugin</artifactId>
119+
<version>3.1.1</version>
120+
<configuration>
121+
<executable>java</executable>
122+
<arguments>
123+
<argument>-noverify</argument>
124+
<argument>-XX:TieredStopAtLevel=1</argument>
125+
<argument>-Dcom.sun.management.jmxremote</argument>
126+
<argument>-classpath</argument>
127+
<classpath/>
128+
<argument>${exec.mainClass}</argument>
129+
</arguments>
130+
</configuration>
131+
</plugin>
132+
<plugin>
133+
<artifactId>maven-surefire-plugin</artifactId>
134+
<version>3.2.5</version>
135+
</plugin>
136+
137+
<plugin>
138+
<groupId>org.apache.maven.plugins</groupId>
139+
<artifactId>maven-compiler-plugin</artifactId>
140+
<version>3.12.1</version>
141+
<configuration>
142+
<encoding>UTF-8</encoding>
143+
<compilerArgs>
144+
<arg>-parameters</arg>
145+
</compilerArgs>
146+
<annotationProcessorPaths>
147+
<path>
148+
<groupId>io.micronaut</groupId>
149+
<artifactId>micronaut-inject-java</artifactId>
150+
<version>${micronaut.version}</version>
151+
</path>
152+
<path>
153+
<groupId>io.micronaut</groupId>
154+
<artifactId>micronaut-validation</artifactId>
155+
<version>${micronaut.version}</version>
156+
</path>
157+
</annotationProcessorPaths>
158+
</configuration>
159+
<executions>
160+
<execution>
161+
<id>test-compile</id>
162+
<goals>
163+
<goal>testCompile</goal>
164+
</goals>
165+
<configuration>
166+
<compilerArgs>
167+
<arg>-parameters</arg>
168+
</compilerArgs>
169+
<annotationProcessorPaths>
170+
<path>
171+
<groupId>io.micronaut</groupId>
172+
<artifactId>micronaut-inject-java</artifactId>
173+
<version>${micronaut.version}</version>
174+
</path>
175+
<path>
176+
<groupId>io.micronaut</groupId>
177+
<artifactId>micronaut-validation</artifactId>
178+
<version>${micronaut.version}</version>
179+
</path>
180+
</annotationProcessorPaths>
181+
</configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
</plugins>
186+
187+
</build>
188+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2023 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+
# [START gae_flex_java25_yaml]
15+
runtime: java
16+
env: flex
17+
service: helloworld-java25-flex
18+
runtime_config:
19+
operating_system: ubuntu24
20+
runtime_version: 25
21+
handlers:
22+
- url: /.*
23+
script: this field is required, but ignored
24+
25+
manual_scaling:
26+
instances: 1
27+
# [END gae_flex_java25_yaml]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2023 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+
package com.example.appengine;
18+
19+
import io.micronaut.runtime.Micronaut;
20+
21+
public class Application {
22+
23+
public static void main(String[] args) {
24+
Micronaut.run(Application.class);
25+
}
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2023 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+
package com.example.appengine;
18+
19+
import io.micronaut.http.MediaType;
20+
import io.micronaut.http.annotation.Controller;
21+
import io.micronaut.http.annotation.Get;
22+
import io.micronaut.http.annotation.Produces;
23+
24+
@Controller("/")
25+
public class HelloController {
26+
@Get("/")
27+
@Produces(MediaType.TEXT_PLAIN)
28+
public String index() {
29+
return "Hello World!";
30+
}
31+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2023 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+
micronaut:
16+
application:
17+
name: micronaut
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!--
2+
Copyright 2023 Google LLC
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+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
-->
13+
14+
<configuration>
15+
16+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
17+
<withJansi>true</withJansi>
18+
<!-- encoders are assigned the type
19+
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
20+
<encoder>
21+
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
22+
</encoder>
23+
</appender>
24+
25+
<root level="info">
26+
<appender-ref ref="STDOUT" />
27+
</root>
28+
</configuration>

0 commit comments

Comments
 (0)