Skip to content

Commit 8543207

Browse files
authored
fix(cloud-run): CloudRun/HelloWorld upgrade to Java25 along Docker (#10276)
* chore(run): upgrade helloworld sample to Java 25 * fix: kokoro btlr compatability only with Java 21 in pom.xml workaround * refactor: migrate tests from JUnit 4 to JUnit 5
1 parent 2c245f7 commit 8543207

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

run/helloworld/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# [START cloudrun_helloworld_dockerfile]
1616
# Use the official maven image to create a build artifact.
1717
# https://hub.docker.com/_/maven
18-
FROM maven:3-eclipse-temurin-17-alpine as builder
18+
FROM maven:3-eclipse-temurin-25-alpine as builder
1919

2020
# Copy local code to the container image.
2121
WORKDIR /app
@@ -27,7 +27,7 @@ RUN mvn package -DskipTests
2727

2828
# Use Eclipse Temurin for base image.
2929
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
30-
FROM eclipse-temurin:17.0.18_8-jre-alpine
30+
FROM eclipse-temurin:25-jre-alpine
3131

3232
# Copy the jar to the production image from the builder stage.
3333
COPY --from=builder /app/target/helloworld-*.jar /helloworld.jar

run/helloworld/pom.xml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License.
2424
<parent>
2525
<groupId>com.google.cloud.samples</groupId>
2626
<artifactId>shared-configuration</artifactId>
27-
<version>1.2.0</version>
27+
<version>1.2.2</version>
2828
</parent>
2929
<dependencyManagement>
3030
<dependencies>
@@ -41,9 +41,10 @@ limitations under the License.
4141
<properties>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
44-
<maven.compiler.target>17</maven.compiler.target>
45-
<maven.compiler.source>17</maven.compiler.source>
46-
<spring-boot.version>3.2.2</spring-boot.version>
44+
<!--Change this to 25 in your workspace-->
45+
<maven.compiler.source>21</maven.compiler.source>
46+
<maven.compiler.target>21</maven.compiler.target>
47+
<spring-boot.version>3.5.0</spring-boot.version>
4748
</properties>
4849
<dependencies>
4950
<dependency>
@@ -68,6 +69,11 @@ limitations under the License.
6869
</dependencies>
6970
<build>
7071
<plugins>
72+
<plugin>
73+
<groupId>org.jacoco</groupId>
74+
<artifactId>jacoco-maven-plugin</artifactId>
75+
<version>0.8.14</version>
76+
</plugin>
7177
<plugin>
7278
<groupId>org.springframework.boot</groupId>
7379
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -84,8 +90,11 @@ limitations under the License.
8490
<plugin>
8591
<groupId>com.google.cloud.tools</groupId>
8692
<artifactId>jib-maven-plugin</artifactId>
87-
<version>3.4.0</version>
93+
<version>3.4.6</version>
8894
<configuration>
95+
<from>
96+
<image>eclipse-temurin:25-jre-alpine</image>
97+
</from>
8998
<to>
9099
<image>gcr.io/PROJECT_ID/helloworld</image>
91100
</to>

run/helloworld/src/test/java/com/example/helloworld/HelloworldApplicationTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@
2020
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
2121
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
2222

23-
import org.junit.Test;
24-
import org.junit.runner.RunWith;
23+
import org.junit.jupiter.api.Test;
2524
import org.springframework.beans.factory.annotation.Autowired;
2625
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
2726
import org.springframework.boot.test.context.SpringBootTest;
28-
import org.springframework.test.context.junit4.SpringRunner;
2927
import org.springframework.test.web.servlet.MockMvc;
3028

31-
@RunWith(SpringRunner.class)
3229
@SpringBootTest
3330
@AutoConfigureMockMvc
3431
public class HelloworldApplicationTests {

0 commit comments

Comments
 (0)