Skip to content

Commit 404adcb

Browse files
authored
update to SpringBoot 3 (temporalio#564)
* update to SpringBoot 3 Signed-off-by: Tihomir Surdilovic <tihomir@temporal.io> * allow support for both spring boot 2 and 3 Signed-off-by: Tihomir Surdilovic <tihomir@temporal.io> --------- Signed-off-by: Tihomir Surdilovic <tihomir@temporal.io>
1 parent a47b3b6 commit 404adcb

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Temporal using the [Java SDK](https://github.com/temporalio/sdk-java).
55

66
It contains two modules:
77
* [Core](/core): showcases many different SDK features.
8-
* [SpringBoot](/springboot): showcases springboot autoconfig integration.
8+
* [SpringBoot](/springboot): showcases SpringBoot autoconfig integration.
99

1010
## Learn more about Temporal and Java SDK
1111

@@ -15,8 +15,9 @@ It contains two modules:
1515

1616
## Requirements
1717

18-
- Java 1.8+ for build and runtime
19-
- Java 11+ for development and contribution
18+
- Java 1.8+ for build and runtime of core samples
19+
- Java 1.8+ for build and runtime of SpringBoot samples when using SpringBoot 2
20+
- Java 1.17+ for build and runtime of Spring Boot samples when using SpringBoot 3
2021
- Local Temporal Server, easiest to get started would be using [Temporal CLI](https://github.com/temporalio/cli).
2122
For more options see docs [here](https://docs.temporal.io/kb/all-the-ways-to-run-a-cluster).
2223

@@ -133,6 +134,9 @@ See the README.md file in each main sample directory for cut/paste Gradle comman
133134

134135
### Running SpringBoot Samples
135136

137+
These samples use SpringBoot 2 by default. To switch to using SpringBoot 3 look at the [gradle.properties](gradle.properties) file
138+
and follow simple instructions there.
139+
136140
1. Start SpringBoot from main repo dir:
137141

138142
./gradlew bootRun

build.gradle

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'org.cadixdev.licenser' version '0.6.1'
33
id "net.ltgt.errorprone" version "3.1.0"
44
id 'com.diffplug.spotless' version '6.22.0' apply false
5-
id 'org.springframework.boot' version '2.7.13'
5+
id "org.springframework.boot" version "${springBootPluginVersion}"
66
}
77

88
subprojects {
@@ -11,15 +11,20 @@ subprojects {
1111
apply plugin: 'net.ltgt.errorprone'
1212
apply plugin: 'com.diffplug.spotless'
1313

14-
java {
15-
sourceCompatibility = JavaVersion.VERSION_1_8
16-
targetCompatibility = JavaVersion.VERSION_1_8
17-
}
18-
1914
compileJava {
2015
options.compilerArgs << "-Werror"
2116
}
2217

18+
java {
19+
if(project.property("springBootPluginVersion") == "2.7.13") {
20+
sourceCompatibility = JavaVersion.VERSION_11
21+
targetCompatibility = JavaVersion.VERSION_11
22+
} else {
23+
sourceCompatibility = JavaVersion.VERSION_17
24+
targetCompatibility = JavaVersion.VERSION_17
25+
}
26+
}
27+
2328
ext {
2429
otelVersion = '1.30.1'
2530
otelVersionAlpha = "${otelVersion}-alpha"
@@ -47,21 +52,18 @@ subprojects {
4752
exclude '**/*.js'
4853
}
4954

50-
if (JavaVersion.current().isJava11Compatible()) {
51-
// Code should be formatted using the latest googleJavaFormat, but it doesn't support Java <11 since version 1.8
52-
apply plugin: 'com.diffplug.spotless'
55+
apply plugin: 'com.diffplug.spotless'
5356

54-
spotless {
55-
java {
56-
target 'src/*/java/**/*.java'
57-
targetExclude '**/.idea/**'
58-
googleJavaFormat('1.16.0')
59-
}
57+
spotless {
58+
java {
59+
target 'src/*/java/**/*.java'
60+
targetExclude '**/.idea/**'
61+
googleJavaFormat('1.16.0')
6062
}
61-
62-
compileJava.dependsOn 'spotlessApply'
6363
}
6464

65+
compileJava.dependsOn 'spotlessApply'
66+
6567
test {
6668
useJUnitPlatform()
6769
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
springBootPluginVersion=2.7.13
2+
3+
# use this for spring boot 3 support
4+
#springBootPluginVersion=3.2.0

springboot/build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ dependencies {
1414
testImplementation "org.springframework.boot:spring-boot-starter-test"
1515
dependencies {
1616
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
17-
if (JavaVersion.current().isJava11Compatible()) {
18-
errorprone('com.google.errorprone:error_prone_core:2.23.0')
19-
} else {
20-
errorprone('com.google.errorprone:error_prone_core:2.23.0')
21-
}
17+
errorprone('com.google.errorprone:error_prone_core:2.23.0')
2218
}
2319
}
2420

0 commit comments

Comments
 (0)