Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support both springboot 2 and 3 #564

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Temporal using the [Java SDK](https://github.com/temporalio/sdk-java).

It contains two modules:
* [Core](/core): showcases many different SDK features.
* [SpringBoot](/springboot): showcases springboot autoconfig integration.
* [SpringBoot](/springboot): showcases SpringBoot autoconfig integration.

## Learn more about Temporal and Java SDK

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

## Requirements

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

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

### Running SpringBoot Samples

These samples use SpringBoot 2 by default. To switch to using SpringBoot 3 look at the [gradle.properties](gradle.properties) file
and follow simple instructions there.

1. Start SpringBoot from main repo dir:

./gradlew bootRun
Expand Down
36 changes: 19 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.cadixdev.licenser' version '0.6.1'
id "net.ltgt.errorprone" version "3.1.0"
id 'com.diffplug.spotless' version '6.22.0' apply false
id 'org.springframework.boot' version '2.7.13'
id "org.springframework.boot" version "${springBootPluginVersion}"
}

subprojects {
Expand All @@ -11,15 +11,20 @@ subprojects {
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.diffplug.spotless'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileJava {
options.compilerArgs << "-Werror"
}

java {
if(project.property("springBootPluginVersion") == "2.7.13") {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
} else {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

ext {
otelVersion = '1.30.1'
otelVersionAlpha = "${otelVersion}-alpha"
Expand Down Expand Up @@ -47,21 +52,18 @@ subprojects {
exclude '**/*.js'
}

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

spotless {
java {
target 'src/*/java/**/*.java'
targetExclude '**/.idea/**'
googleJavaFormat('1.16.0')
}
spotless {
java {
target 'src/*/java/**/*.java'
targetExclude '**/.idea/**'
googleJavaFormat('1.16.0')
}

compileJava.dependsOn 'spotlessApply'
}

compileJava.dependsOn 'spotlessApply'

test {
useJUnitPlatform()
}
Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
springBootPluginVersion=2.7.13

# use this for spring boot 3 support
#springBootPluginVersion=3.2.0
6 changes: 1 addition & 5 deletions springboot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ dependencies {
testImplementation "org.springframework.boot:spring-boot-starter-test"
dependencies {
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
if (JavaVersion.current().isJava11Compatible()) {
errorprone('com.google.errorprone:error_prone_core:2.23.0')
} else {
errorprone('com.google.errorprone:error_prone_core:2.23.0')
}
errorprone('com.google.errorprone:error_prone_core:2.23.0')
}
}

Expand Down