diff --git a/README.md b/README.md index f7846128..320be8f4 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). @@ -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 diff --git a/build.gradle b/build.gradle index 75b8d0cd..663a8f2d 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { @@ -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" @@ -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() } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..28873879 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +springBootPluginVersion=2.7.13 + +# use this for spring boot 3 support +#springBootPluginVersion=3.2.0 diff --git a/springboot/build.gradle b/springboot/build.gradle index 6f09712a..569e1cc9 100644 --- a/springboot/build.gradle +++ b/springboot/build.gradle @@ -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') } }