Follow these steps in a fresh directory to recreate a Gradle multi-module project like temporalio-samples-java. Commands assume the default macOS Terminal (zsh) and Homebrew-installed tooling.
-
Prepare prerequisites
- Install Temportal CLI and Java (
brew install temporal gradle openjdk@17) if you have not already. - Ensure the desired JDK is on the PATH:
/usr/libexec/java_home -V # verify installed versions export PATH="/opt/homebrew/opt/openjdk@17/bin:$PATH"
- Install Temportal CLI and Java (
-
Create the root directory
mkdir temporalio-samples-java cd temporalio-samples-java -
Initialize Gradle
gradle init --type basic ./gradlew wrapper --gradle-version 8.7
This seeds
settings.gradle,build.gradle, and the Gradle wrapper. -
Declare subprojects Edit
settings.gradleso it lists every module you need:rootProject.name = "temporalio-samples-java" include("core", "springboot", "springboot-basic", "docker")
-
Create module folders
for module in core springboot springboot-basic docker; do mkdir -p "$module/src/main/java" "$module/src/test/java" done
-
Author the root build Populate
build.gradlewith the shared configuration (Temporal SDK version, Java plugins, repositories).plugins { id("java") } group = "io.temporal.samples" version = "1.0.0-SNAPSHOT" subprojects { apply(plugin = "java") java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } repositories { mavenCentral() } dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") } tasks.test { useJUnitPlatform() } } -
Add module-specific build files
core/build.gradle:dependencies { implementation("io.temporal:temporal-sdk:1.24.0") }springboot/build.gradle&springboot-basic/build.gradle: apply Spring Boot plugin and add Web + Temporal dependencies.plugins { id("org.springframework.boot") version "3.2.5" id("io.spring.dependency-management") version "1.1.4" } dependencies { implementation("io.temporal:temporal-spring-boot-starter-alpha:1.24.0") implementation("org.springframework.boot:spring-boot-starter-web") testImplementation("org.springframework.boot:spring-boot-starter-test") }
-
Add source packages Inside each module, create packages such as
io.temporal.samples.hello, and add placeholder workflow/activity classes plus matching tests undersrc/test/java. -
Check formatting and run the build
./gradlew spotlessApply # optional, once Spotless is configured ./gradlew build -
Run samples
- Core workflow driver:
./gradlew :core:run --args='HelloActivity'. - Spring Boot app:
./gradlew :springboot:bootRun.
- Core workflow driver:
With this scaffold in place you can begin porting or authoring workflows, activities, and Spring endpoints following the sample modules already organized under io.temporal.samples.