From 0119f5a6f38c16aab63f1be5583d0e70b4bee43e Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Tue, 19 Aug 2025 18:19:34 -0400 Subject: [PATCH 1/3] Changing formatter plugin, add license check, add formatters githooks Signed-off-by: Ricardo Zanini --- .githooks/pre-commit | 30 ++++++++++ .github/workflows/maven-verify.yml | 4 ++ Makefile | 47 ++++++++++++++++ config/license-header.txt | 15 +++++ .../func/JavaForExecutorBuilder.java | 1 - .../func/JavaListenExecutorBuilder.java | 1 - .../func/JavaSwitchExecutorBuilder.java | 1 - .../fluent/agentic/WorkflowTests.java | 1 - generators/types/pom.xml | 24 -------- .../impl/events/TypeEventRegistration.java | 1 - .../events/TypeEventRegistrationBuilder.java | 1 - .../impl/expressions/RuntimeDescriptor.java | 1 - .../impl/lifecycle/TaskCompletedEvent.java | 1 - pom.xml | 55 +++++++------------ scripts/install-git-hooks.sh | 5 ++ 15 files changed, 120 insertions(+), 68 deletions(-) create mode 100755 .githooks/pre-commit create mode 100644 Makefile create mode 100644 config/license-header.txt create mode 100755 scripts/install-git-hooks.sh diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..e27d2fe3 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(git rev-parse --show-toplevel)" + +# which Java files are staged? +mapfile -t STAGED_JAVA < <(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.java$' || true) +[ ${#STAGED_JAVA[@]} -eq 0 ] && exit 0 + +# stash unstaged changes so we don't accidentally commit them +git stash -q --keep-index --include-untracked + +# Build regexes for Spotless' -DspotlessFiles (matches absolute paths) +# escape regex metachars, then anchor to ^$ with absolute path +PATTERNS="$( + printf "%s\n" "${STAGED_JAVA[@]}" \ + | sed -e 's/[.[\*^$()+?{}|\\]/\\&/g' -e "s|^|^$ROOT/|" -e 's|$|$|' \ + | paste -sd, - +)" + +# run Spotless just on those files (adds headers + formats) +mvn -q -DskipTests -DspotlessFiles="$PATTERNS" spotless:apply + +# re-stage exactly what was staged before +git add -- "${STAGED_JAVA[@]}" + +# restore unstaged changes (may conflict if they touch the same lines the formatter changed) +git stash pop -q || true + +exit 0 diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 74e3dd69..515867fd 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -25,6 +25,10 @@ jobs: java-version: 17 cache: 'maven' + - name: Check formatting + run: | + make ci + # 3. Verify the main sdk-java project, excluding the two agentic modules - name: Verify with Maven run: | diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..d1616006 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +# Makefile +# NOTE: each command line below begins with a literal TAB character. + +MVN ?= mvn +MVN_FLAGS ?= -q -DskipTests + +.PHONY: help hooks format check verify ci status clean + +help: + @echo "" + @echo "Targets:" + @echo " make hooks - Install/enable repo-local git hooks" + @echo " make format - Spotless apply (format + license headers)" + @echo " make check - Spotless check + Checkstyle" + @echo " make verify - mvn verify" + @echo " make ci - CI checks (Spotless + Checkstyle, no tests)" + @echo " make status - Show git hooksPath" + @echo " make clean - mvn clean" + @echo "" + +hooks: + @bash scripts/install-git-hooks.sh + @echo "✅ Git hooks ready." + +format: + @echo "✨ Formatting (Spotless apply + headers)…" + @$(MVN) $(MVN_FLAGS) spotless:apply + +check: + @echo "🔍 Checking format + headers + checkstyle…" + @$(MVN) $(MVN_FLAGS) spotless:check checkstyle:check + +verify: + @echo "🧪 Running mvn verify…" + @$(MVN) -B verify + +ci: + @echo "🏗️ CI checks (no tests)…" + @$(MVN) -B -DskipTests spotless:check checkstyle:check + +status: + @echo -n "hooksPath: " + @git config --get core.hooksPath || echo "(not set)" + +clean: + @echo "🧹 Cleaning…" + @$(MVN) -q clean diff --git a/config/license-header.txt b/config/license-header.txt new file mode 100644 index 00000000..3a4a5564 --- /dev/null +++ b/config/license-header.txt @@ -0,0 +1,15 @@ +/* + * Copyright 2020-Present The Serverless Workflow Specification Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ \ No newline at end of file diff --git a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java index fd11eae1..2f8ec073 100644 --- a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java +++ b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.executors.func; import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.safeObject; diff --git a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaListenExecutorBuilder.java b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaListenExecutorBuilder.java index 3471cee3..295610bb 100644 --- a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaListenExecutorBuilder.java +++ b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaListenExecutorBuilder.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.executors.func; import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.predObject; diff --git a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaSwitchExecutorBuilder.java b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaSwitchExecutorBuilder.java index 2fe04b9c..b8163c4f 100644 --- a/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaSwitchExecutorBuilder.java +++ b/experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaSwitchExecutorBuilder.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.executors.func; import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.predObject; diff --git a/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java b/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java index d38e863c..09cc12cc 100644 --- a/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java +++ b/fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.fluent.agentic; import static io.serverlessworkflow.fluent.agentic.Agents.*; diff --git a/generators/types/pom.xml b/generators/types/pom.xml index 232009ea..215e390f 100644 --- a/generators/types/pom.xml +++ b/generators/types/pom.xml @@ -19,28 +19,4 @@ - - - - com.spotify.fmt - fmt-maven-plugin - - src/main/java - src/test/java - false - .*\.java - false - false - - - - - - format - - - - - - \ No newline at end of file diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistration.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistration.java index 8fdf2388..c5828e72 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistration.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistration.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.events; import io.cloudevents.CloudEvent; diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistrationBuilder.java b/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistrationBuilder.java index bd504a76..39a2a699 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistrationBuilder.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistrationBuilder.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.events; public record TypeEventRegistrationBuilder(String type, CloudEventPredicate cePredicate) diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/expressions/RuntimeDescriptor.java b/impl/core/src/main/java/io/serverlessworkflow/impl/expressions/RuntimeDescriptor.java index 66286632..e9893ed8 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/expressions/RuntimeDescriptor.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/expressions/RuntimeDescriptor.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.expressions; import java.util.Map; diff --git a/impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCompletedEvent.java b/impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCompletedEvent.java index e7ab1084..a4e36156 100644 --- a/impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCompletedEvent.java +++ b/impl/core/src/main/java/io/serverlessworkflow/impl/lifecycle/TaskCompletedEvent.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.serverlessworkflow.impl.lifecycle; import io.serverlessworkflow.impl.TaskContext; diff --git a/pom.xml b/pom.xml index 79d7182f..f18238f9 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,7 @@ 3.2.1 3.6.0 + 2.43.0 3.14.0 3.1.4 3.6.1 @@ -93,28 +94,12 @@ true - - java true **/*IT.java + + ${maven.multiModuleProjectDirectory} @@ -282,10 +267,6 @@ - - - - @@ -317,26 +298,28 @@ - com.spotify.fmt - fmt-maven-plugin + com.diffplug.spotless + spotless-maven-plugin - src/main/java - src/test/java - false - .*\.java - false - false - + + + + + + ${rootDir}/config/license-header.txt + + + + verify - format + check - @@ -470,9 +453,9 @@ ${version.checkstyle.plugin} - com.spotify.fmt - fmt-maven-plugin - ${version.fmt-maven-plugin} + com.diffplug.spotless + spotless-maven-plugin + ${version.com.diffplug.spotless} org.apache.maven.plugins diff --git a/scripts/install-git-hooks.sh b/scripts/install-git-hooks.sh new file mode 100755 index 00000000..1b8257f4 --- /dev/null +++ b/scripts/install-git-hooks.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail +git config core.hooksPath .githooks +chmod +x .githooks/pre-commit +echo "✅ Git hooks installed (core.hooksPath=.githooks)" From 14ea7e70a14aa7582031382e9764056b768acdd1 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Tue, 19 Aug 2025 18:30:42 -0400 Subject: [PATCH 2/3] Add a meaningful CONTRIB.md Signed-off-by: Ricardo Zanini --- CONTRIBUTING.md | 176 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 173 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe76d40a..8f0016b0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,175 @@ -## Hacking on Serverless Workflow Java SDK in Gitpod +# Contributing -If you have a web browser, you can get a fully pre-configured development environment in one click: +Thanks for helping improve this project! This guide explains the local dev setup, the formatting/licensing workflow, testing, and how to propose changes. -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/serverlessworkflow/sdk-java) \ No newline at end of file +--- + +## TL;DR (Fast path) + +1. **Install prerequisites:** JDK 17+, Maven 3.8+, Git, Make, Bash. +2. **Clone** the repo and create a branch: `git checkout -b my-fix`. +3. **Install the repo’s pre-commit hook:** `make hooks` (one-time). +4. **Commit normally.** The pre-commit hook will auto-format Java files and **add license headers**, restage the changes, and let the commit proceed. +5. **Before pushing:** `make check` to run Spotless + Checkstyle locally. +6. **Open a PR** with a clear title and description. + +--- + +## Project Conventions + +### Java, Maven, and modules + +* This is a **multi-module Maven** project. +* **Java 17** is the baseline. +* Build with `mvn -B verify` (CI runs with `-DskipTests` selectively when needed). + +### Formatting and License Headers + +We use **Spotless** (Maven) to: + +* Format Java with **google-java-format**. +* Insert/normalize **license headers** from `config/license-header.txt`. + +> **Do not** hand-format files or hand-edit headers; let Spotless do it. The pre-commit hook runs `spotless:apply` for staged Java files. + +Spotless is configured in the **parent POM** and resolves the header file using: + +``` +${maven.multiModuleProjectDirectory}/config/license-header.txt +``` + +so children modules pick up the root header correctly. + +### Checkstyle + +We keep **Checkstyle** to enforce additional rules. CI fails if formatting or style checks fail. + +--- + +## Developer Setup + +### Prerequisites + +* **JDK 17+** +* **Maven 3.8+** +* **Git**, **Make**, **Bash** +* Optional IDE plugins: + + * IntelliJ: *Google Java Format* plugin (for local editing experience). Spotless remains the source of truth. + +### Install the Git Hooks (one-time) + +```bash +make hooks +``` + +This calls `scripts/install-git-hooks.sh` which sets `core.hooksPath` to `.githooks` and marks hooks executable. + +### Pre-commit Hook Behavior + +* Runs only on **staged** `*.java` files. +* Temporarily stashes unstaged edits (to avoid committing them), runs Spotless, **re-stages** formatted files, then restores the stash. +* If it reformats something, your commit still proceeds with the updated index. + +If something goes wrong: + +* Run `make format` to apply formatting to the whole repo. +* Stage changes and commit again. + +--- + +## Make Targets + +Common tasks are wrapped in a Makefile: + +```text +make hooks # Install/enable repo-local git hooks +make format # Spotless apply (format + license headers) +make check # Spotless check + Checkstyle check +make verify # mvn verify (full build) +make ci # CI checks (Spotless + Checkstyle, no tests) +make clean # mvn clean +``` + +> If `make` complains about a “missing separator”, ensure each command line under a target starts with a **TAB**. + +--- + +## Testing + +* **Unit tests:** `mvn -q test` or `mvn verify`. +* **Integration tests (if defined):** Use the dedicated Maven profile exposed by the module, e.g. `-Pintegration-tests`. +* Prefer fast, deterministic tests. Avoid time-sensitive sleeps; use time abstractions or awaitility-style utilities. + +### Test Guidelines + +* Use clear, behavior-driven names: `methodName_shouldDoX_whenY`. +* Keep one logical assertion per test (or one behavior per test). +* Mock only external dependencies; don’t over-mock domain logic. +* Make tests independent; no ordering assumptions. + +--- + +## Commit & PR Guidelines + +### Branching + +* Use short, descriptive names: `fix/formatter`, `feat/http-call`, `docs/contributing`. + +### Commit messages + +* Keep messages clear and imperative: `Fix header resolution for child modules`. +* Conventional Commits are welcome (`feat:`, `fix:`, `docs:`, `test:`, `refactor:`). Example: `feat: add A2A call task support`. + +### Pull Requests + +* Describe the **problem**, the **solution**, and any **trade-offs**. +* Include before/after snippets or screenshots when relevant. +* Link related issues. +* Check the box: + + * [ ] `make check` passes locally + * [ ] Unit/integration tests updated + * [ ] Public API changes documented/Javadoc updated + * [ ] No unrelated formatting churn (Spotless should keep this minimal) + +--- + +## Code Style & Design Notes + +* **Immutability first:** prefer `final` fields and defensive copies. +* **Null-safety:** use `Objects.requireNonNull` at boundaries; consider `Optional` for truly optional returns (don’t use it for fields/params). +* **Exceptions:** throw specific exceptions; include actionable messages; don’t swallow errors. +* **Logging:** use SLF4J; no `System.out.println`; keep logs structured and at appropriate levels. +* **APIs:** document with Javadoc; avoid breaking changes to public APIs unless necessary and called out in release notes. +* **Generics & type-safety:** prefer precise types over `Object`; isolate unchecked casts. +* **Performance:** avoid premature optimization; measure first; add micro-benchmarks (JMH) when optimizing hot paths. + +--- + +## License Headers + +* Header template lives at: `config/license-header.txt` (root). +* Spotless inserts or normalizes it automatically. +* If the copyright line needs updates, edit the template and run `make format`. + +--- + +## CI + +* CI runs `spotless:check` and `checkstyle:check` to ensure consistent formatting and style. +* Builds fail if formatting or headers drift. Run `make format` locally to fix. + +--- + +## Troubleshooting + +* **Hook didn’t run?** Did you run `make hooks` after cloning? Check `git config --get core.hooksPath` prints `.githooks`. +* **Header file not found?** Ensure Spotless uses the root path via `${maven.multiModuleProjectDirectory}/config/license-header.txt`. +* **Formatting conflicts with unstaged edits?** The hook stashes them. If a conflict occurs, complete the merge in your working copy, then `git add` and commit again. + +--- + +## Questions + +Open a discussion or issue on the repository. Thanks for contributing! 🎉 From d0848344a166a7e4dfba14acd7da474a0a4cb331 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Wed, 20 Aug 2025 09:26:52 -0400 Subject: [PATCH 3/3] Remove Makefile, make spotless format and add headers on mvn clean Signed-off-by: Ricardo Zanini --- .githooks/pre-commit | 30 ----------- .github/workflows/maven-verify.yml | 44 +++++++++------- CONTRIBUTING.md | 83 ++++++++---------------------- Makefile | 47 ----------------- config/license-header.txt | 15 ------ examples/events/pom.xml | 14 +++++ examples/simpleGet/pom.xml | 16 ++++++ pom.xml | 43 ++++++++++++++-- scripts/install-git-hooks.sh | 5 -- 9 files changed, 116 insertions(+), 181 deletions(-) delete mode 100755 .githooks/pre-commit delete mode 100644 Makefile delete mode 100644 config/license-header.txt delete mode 100755 scripts/install-git-hooks.sh diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index e27d2fe3..00000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -ROOT="$(git rev-parse --show-toplevel)" - -# which Java files are staged? -mapfile -t STAGED_JAVA < <(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.java$' || true) -[ ${#STAGED_JAVA[@]} -eq 0 ] && exit 0 - -# stash unstaged changes so we don't accidentally commit them -git stash -q --keep-index --include-untracked - -# Build regexes for Spotless' -DspotlessFiles (matches absolute paths) -# escape regex metachars, then anchor to ^$ with absolute path -PATTERNS="$( - printf "%s\n" "${STAGED_JAVA[@]}" \ - | sed -e 's/[.[\*^$()+?{}|\\]/\\&/g' -e "s|^|^$ROOT/|" -e 's|$|$|' \ - | paste -sd, - -)" - -# run Spotless just on those files (adds headers + formats) -mvn -q -DskipTests -DspotlessFiles="$PATTERNS" spotless:apply - -# re-stage exactly what was staged before -git add -- "${STAGED_JAVA[@]}" - -# restore unstaged changes (may conflict if they touch the same lines the formatter changed) -git stash pop -q || true - -exit 0 diff --git a/.github/workflows/maven-verify.yml b/.github/workflows/maven-verify.yml index 515867fd..c2f47dae 100644 --- a/.github/workflows/maven-verify.yml +++ b/.github/workflows/maven-verify.yml @@ -2,39 +2,45 @@ name: sdk-java Verify on: push: - branches: - - main + branches: [ main ] pull_request: - branches: - - main + branches: [ main ] jobs: - build: + lint: + name: Lint (Spotless + Checkstyle) runs-on: ubuntu-latest - steps: - # 1. Checkout this repo - name: Checkout sdk-java uses: actions/checkout@v4 - # 2. Set up JDK 17 for both builds - name: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: temurin java-version: 17 - cache: 'maven' + cache: maven - - name: Check formatting - run: | - make ci + - name: Spotless + Checkstyle (fail fast) + run: mvn -B -DskipTests spotless:check checkstyle:check - # 3. Verify the main sdk-java project, excluding the two agentic modules - - name: Verify with Maven - run: | - mvn -B -f pom.xml clean install verify -am + build: + name: Build & Verify + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout sdk-java + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: maven - # 4. Verify examples - - name: Verify Examples with Maven + - name: Verify with Maven (core) run: | - mvn -B -f examples/pom.xml clean install verify + mvn -B -f pom.xml clean verify + + # TODO: run examples once we fix the close issue diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f0016b0..0b0ddfaf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,12 +6,11 @@ Thanks for helping improve this project! This guide explains the local dev setup ## TL;DR (Fast path) -1. **Install prerequisites:** JDK 17+, Maven 3.8+, Git, Make, Bash. +1. **Install prerequisites:** JDK 17+, Maven 3.8+, Git. 2. **Clone** the repo and create a branch: `git checkout -b my-fix`. -3. **Install the repo’s pre-commit hook:** `make hooks` (one-time). -4. **Commit normally.** The pre-commit hook will auto-format Java files and **add license headers**, restage the changes, and let the commit proceed. -5. **Before pushing:** `make check` to run Spotless + Checkstyle locally. -6. **Open a PR** with a clear title and description. +3. **Build locally:** run `mvn clean install` from the repo root. Spotless will **apply formatting and license headers** during the build. +4. **Before pushing:** run `mvn -DskipTests spotless:check checkstyle:check`. +5. **Open a PR** with a clear title and description. --- @@ -28,17 +27,9 @@ Thanks for helping improve this project! This guide explains the local dev setup We use **Spotless** (Maven) to: * Format Java with **google-java-format**. -* Insert/normalize **license headers** from `config/license-header.txt`. +* Insert/normalize **license headers** (the header content is defined **inline** in the parent POM’s `` configuration). -> **Do not** hand-format files or hand-edit headers; let Spotless do it. The pre-commit hook runs `spotless:apply` for staged Java files. - -Spotless is configured in the **parent POM** and resolves the header file using: - -``` -${maven.multiModuleProjectDirectory}/config/license-header.txt -``` - -so children modules pick up the root header correctly. +> **Do not** hand-format files or hand-edit headers; let Spotless do it. Running `mvn clean install` locally will mutate sources to match the standard. ### Checkstyle @@ -52,46 +43,15 @@ We keep **Checkstyle** to enforce additional rules. CI fails if formatting or st * **JDK 17+** * **Maven 3.8+** -* **Git**, **Make**, **Bash** +* **Git** * Optional IDE plugins: - * IntelliJ: *Google Java Format* plugin (for local editing experience). Spotless remains the source of truth. - -### Install the Git Hooks (one-time) - -```bash -make hooks -``` - -This calls `scripts/install-git-hooks.sh` which sets `core.hooksPath` to `.githooks` and marks hooks executable. - -### Pre-commit Hook Behavior - -* Runs only on **staged** `*.java` files. -* Temporarily stashes unstaged edits (to avoid committing them), runs Spotless, **re-stages** formatted files, then restores the stash. -* If it reformats something, your commit still proceeds with the updated index. - -If something goes wrong: - -* Run `make format` to apply formatting to the whole repo. -* Stage changes and commit again. - ---- - -## Make Targets - -Common tasks are wrapped in a Makefile: + * IntelliJ: *Google Java Format* plugin (for local editing experience). Spotless remains the source of truth. -```text -make hooks # Install/enable repo-local git hooks -make format # Spotless apply (format + license headers) -make check # Spotless check + Checkstyle check -make verify # mvn verify (full build) -make ci # CI checks (Spotless + Checkstyle, no tests) -make clean # mvn clean -``` +### Local build & formatting -> If `make` complains about a “missing separator”, ensure each command line under a target starts with a **TAB**. +* Run `mvn clean install` from the repo root. During the build, Spotless **applies** formatting and license headers. +* Before pushing, run `mvn -DskipTests spotless:check checkstyle:check` to ensure CI will pass. --- @@ -128,10 +88,10 @@ make clean # mvn clean * Link related issues. * Check the box: - * [ ] `make check` passes locally - * [ ] Unit/integration tests updated - * [ ] Public API changes documented/Javadoc updated - * [ ] No unrelated formatting churn (Spotless should keep this minimal) + * [ ] `mvn -DskipTests spotless:check checkstyle:check` passes locally + * [ ] Unit/integration tests updated + * [ ] Public API changes documented/Javadoc updated + * [ ] No unrelated formatting churn (Spotless should keep this minimal) --- @@ -149,24 +109,23 @@ make clean # mvn clean ## License Headers -* Header template lives at: `config/license-header.txt` (root). -* Spotless inserts or normalizes it automatically. -* If the copyright line needs updates, edit the template and run `make format`. +* The license header is defined **inline** in the parent POM under Spotless’ ``. +* To update it, edit the parent POM and run `mvn spotless:apply` to propagate changes. --- ## CI * CI runs `spotless:check` and `checkstyle:check` to ensure consistent formatting and style. -* Builds fail if formatting or headers drift. Run `make format` locally to fix. +* Builds fail if formatting or headers drift. Run `mvn spotless:apply` locally to fix. --- ## Troubleshooting -* **Hook didn’t run?** Did you run `make hooks` after cloning? Check `git config --get core.hooksPath` prints `.githooks`. -* **Header file not found?** Ensure Spotless uses the root path via `${maven.multiModuleProjectDirectory}/config/license-header.txt`. -* **Formatting conflicts with unstaged edits?** The hook stashes them. If a conflict occurs, complete the merge in your working copy, then `git add` and commit again. +* **Spotless changed files during build?** That’s expected locally. Review `git status`, then stage and commit the updates. +* **CI red on formatting?** Run `mvn spotless:apply` locally, commit, and push. +* **Running only a submodule?** Prefer `mvn -pl -am …` from the repo root so parent config (Spotless/Checkstyle) is applied consistently. --- diff --git a/Makefile b/Makefile deleted file mode 100644 index d1616006..00000000 --- a/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Makefile -# NOTE: each command line below begins with a literal TAB character. - -MVN ?= mvn -MVN_FLAGS ?= -q -DskipTests - -.PHONY: help hooks format check verify ci status clean - -help: - @echo "" - @echo "Targets:" - @echo " make hooks - Install/enable repo-local git hooks" - @echo " make format - Spotless apply (format + license headers)" - @echo " make check - Spotless check + Checkstyle" - @echo " make verify - mvn verify" - @echo " make ci - CI checks (Spotless + Checkstyle, no tests)" - @echo " make status - Show git hooksPath" - @echo " make clean - mvn clean" - @echo "" - -hooks: - @bash scripts/install-git-hooks.sh - @echo "✅ Git hooks ready." - -format: - @echo "✨ Formatting (Spotless apply + headers)…" - @$(MVN) $(MVN_FLAGS) spotless:apply - -check: - @echo "🔍 Checking format + headers + checkstyle…" - @$(MVN) $(MVN_FLAGS) spotless:check checkstyle:check - -verify: - @echo "🧪 Running mvn verify…" - @$(MVN) -B verify - -ci: - @echo "🏗️ CI checks (no tests)…" - @$(MVN) -B -DskipTests spotless:check checkstyle:check - -status: - @echo -n "hooksPath: " - @git config --get core.hooksPath || echo "(not set)" - -clean: - @echo "🧹 Cleaning…" - @$(MVN) -q clean diff --git a/config/license-header.txt b/config/license-header.txt deleted file mode 100644 index 3a4a5564..00000000 --- a/config/license-header.txt +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright 2020-Present The Serverless Workflow Specification Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ \ No newline at end of file diff --git a/examples/events/pom.xml b/examples/events/pom.xml index 439b3a11..e1461497 100644 --- a/examples/events/pom.xml +++ b/examples/events/pom.xml @@ -8,6 +8,12 @@ Serverless Workflow :: Examples :: Events serverlessworkflow-examples-events + + + events.EventExample + + + io.serverlessworkflow @@ -18,4 +24,12 @@ slf4j-simple + + + + org.codehaus.mojo + exec-maven-plugin + + + \ No newline at end of file diff --git a/examples/simpleGet/pom.xml b/examples/simpleGet/pom.xml index 1a913363..f8d853b3 100644 --- a/examples/simpleGet/pom.xml +++ b/examples/simpleGet/pom.xml @@ -8,6 +8,11 @@ serverlessworkflow-examples-simpleGet Serverless Workflow :: Examples :: SimpleGet + + + io.serverlessworkflow.impl.BlockingExample + + io.serverlessworkflow @@ -30,4 +35,15 @@ slf4j-simple + + + + org.codehaus.mojo + exec-maven-plugin + + ${mainClass} + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index f18238f9..b9fa70bd 100644 --- a/pom.xml +++ b/pom.xml @@ -63,12 +63,12 @@ 3.1.4 3.6.1 3.5.3 - 2.27 3.2.8 3.4.2 ${java.version} 1.2.2 3.11.3 + 3.5.1 3.1.1 3.3.1 3.5.3 @@ -306,13 +306,38 @@ - ${rootDir}/config/license-header.txt + + + - + spotless-apply-on-validate + validate + + apply + + + + spotless-check-on-verify verify check @@ -494,6 +519,18 @@ false + + org.codehaus.mojo + exec-maven-plugin + ${version.org.codehaus.mojo} + + + + java + + + + diff --git a/scripts/install-git-hooks.sh b/scripts/install-git-hooks.sh deleted file mode 100755 index 1b8257f4..00000000 --- a/scripts/install-git-hooks.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -git config core.hooksPath .githooks -chmod +x .githooks/pre-commit -echo "✅ Git hooks installed (core.hooksPath=.githooks)"