Skip to content

Commit a094073

Browse files
authored
feat: add GAE Flex samples for Java25 (#10196)
* feat: add flexible samples * Addressing auto-review comments and taking comments from previous PR #10193 * Changing Java25 Micronaut and Websocket Flex samples to bytecode java21 since java25 is not yet stable in Micronaut and Websocket Jetty ecosystem. * Fixing EE8 GAE 21 sample to be complied to Java21.
1 parent dc863ea commit a094073

File tree

23 files changed

+1427
-3
lines changed

23 files changed

+1427
-3
lines changed

appengine-java21/ee8/analytics/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
</parent>
3333

3434
<properties>
35-
<maven.compiler.target>1.8</maven.compiler.target>
36-
<maven.compiler.source>1.8</maven.compiler.source>
37-
<appengine.sdk.version>2.0.23</appengine.sdk.version>
35+
<maven.compiler.target>21</maven.compiler.target>
36+
<maven.compiler.source>21</maven.compiler.source>
37+
<appengine.sdk.version>3.0.1</appengine.sdk.version>
3838
</properties>
3939

4040
<dependencyManagement>
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: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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+
<jacoco.agent.argLine>${argLine}</jacoco.agent.argLine>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>io.micronaut</groupId>
43+
<artifactId>micronaut-inject</artifactId>
44+
<version>${micronaut.version}</version>
45+
<scope>compile</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>io.micronaut</groupId>
49+
<artifactId>micronaut-validation</artifactId>
50+
<version>${micronaut.version}</version>
51+
<scope>compile</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>io.micronaut</groupId>
55+
<artifactId>micronaut-runtime</artifactId>
56+
<version>${micronaut.version}</version>
57+
<scope>compile</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>io.micronaut</groupId>
61+
<artifactId>micronaut-http-client</artifactId>
62+
<version>${micronaut.version}</version>
63+
<scope>compile</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>javax.annotation</groupId>
67+
<artifactId>javax.annotation-api</artifactId>
68+
<version>1.3.2</version>
69+
<scope>compile</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.micronaut</groupId>
73+
<artifactId>micronaut-http-server-netty</artifactId>
74+
<version>${micronaut.version}</version>
75+
<scope>compile</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>junit</groupId>
79+
<artifactId>junit</artifactId>
80+
<version>4.13.2</version>
81+
<scope>test</scope>
82+
</dependency>
83+
</dependencies>
84+
85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>com.google.cloud.tools</groupId>
89+
<artifactId>appengine-maven-plugin</artifactId>
90+
<version>2.8.3</version>
91+
<configuration>
92+
<projectId>GCLOUD_CONFIG</projectId>
93+
<version>micronaut-helloworld</version>
94+
</configuration>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-shade-plugin</artifactId>
99+
<version>3.5.2</version>
100+
<executions>
101+
<execution>
102+
<phase>package</phase>
103+
<goals>
104+
<goal>shade</goal>
105+
</goals>
106+
<configuration>
107+
<transformers>
108+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
109+
<mainClass>${exec.mainClass}</mainClass>
110+
</transformer>
111+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
112+
</transformers>
113+
</configuration>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
<plugin>
118+
<groupId>org.codehaus.mojo</groupId>
119+
<artifactId>exec-maven-plugin</artifactId>
120+
<version>3.2.0</version>
121+
<configuration>
122+
<executable>java</executable>
123+
<arguments>
124+
<argument>-noverify</argument>
125+
<argument>-XX:TieredStopAtLevel=1</argument>
126+
<argument>-Dcom.sun.management.jmxremote</argument>
127+
<argument>-classpath</argument>
128+
<classpath/>
129+
<argument>${exec.mainClass}</argument>
130+
</arguments>
131+
</configuration>
132+
</plugin>
133+
<plugin>
134+
<artifactId>maven-surefire-plugin</artifactId>
135+
<version>3.2.2</version>
136+
</plugin>
137+
138+
<plugin>
139+
<groupId>org.apache.maven.plugins</groupId>
140+
<artifactId>maven-compiler-plugin</artifactId>
141+
<version>3.12.1</version>
142+
<configuration>
143+
<encoding>UTF-8</encoding>
144+
<compilerArgs>
145+
<arg>-parameters</arg>
146+
</compilerArgs>
147+
<annotationProcessorPaths>
148+
<path>
149+
<groupId>io.micronaut</groupId>
150+
<artifactId>micronaut-inject-java</artifactId>
151+
<version>${micronaut.version}</version>
152+
</path>
153+
<path>
154+
<groupId>io.micronaut</groupId>
155+
<artifactId>micronaut-validation</artifactId>
156+
<version>${micronaut.version}</version>
157+
</path>
158+
</annotationProcessorPaths>
159+
</configuration>
160+
<executions>
161+
<execution>
162+
<id>test-compile</id>
163+
<goals>
164+
<goal>testCompile</goal>
165+
</goals>
166+
<configuration>
167+
<compilerArgs>
168+
<arg>-parameters</arg>
169+
</compilerArgs>
170+
<annotationProcessorPaths>
171+
<path>
172+
<groupId>io.micronaut</groupId>
173+
<artifactId>micronaut-inject-java</artifactId>
174+
<version>${micronaut.version}</version>
175+
</path>
176+
<path>
177+
<groupId>io.micronaut</groupId>
178+
<artifactId>micronaut-validation</artifactId>
179+
<version>${micronaut.version}</version>
180+
</path>
181+
</annotationProcessorPaths> </configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
<plugin>
186+
<groupId>org.jacoco</groupId>
187+
<artifactId>jacoco-maven-plugin</artifactId>
188+
<version>0.8.12</version>
189+
<executions>
190+
<execution>
191+
<goals>
192+
<goal>prepare-agent</goal>
193+
</goals>
194+
</execution>
195+
<execution>
196+
<id>report</id>
197+
<phase>prepare-package</phase>
198+
<goals>
199+
<goal>report</goal>
200+
</goals>
201+
</execution>
202+
</executions>
203+
</plugin>
204+
</plugins>
205+
206+
</build>
207+
</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)