|
1 |
| -## Hacking on Serverless Workflow Java SDK in Gitpod |
| 1 | +# Contributing |
2 | 2 |
|
3 |
| -If you have a web browser, you can get a fully pre-configured development environment in one click: |
| 3 | +Thanks for helping improve this project! This guide explains the local dev setup, the formatting/licensing workflow, testing, and how to propose changes. |
4 | 4 |
|
5 |
| -[](https://gitpod.io/#https://github.com/serverlessworkflow/sdk-java) |
| 5 | +--- |
| 6 | + |
| 7 | +## TL;DR (Fast path) |
| 8 | + |
| 9 | +1. **Install prerequisites:** JDK 17+, Maven 3.8+, Git. |
| 10 | +2. **Clone** the repo and create a branch: `git checkout -b my-fix`. |
| 11 | +3. **Build locally:** run `mvn clean install` from the repo root. Spotless will **apply formatting and license headers** during the build. |
| 12 | +4. **Before pushing:** run `mvn -DskipTests spotless:check checkstyle:check`. |
| 13 | +5. **Open a PR** with a clear title and description. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Project Conventions |
| 18 | + |
| 19 | +### Java, Maven, and modules |
| 20 | + |
| 21 | +* This is a **multi-module Maven** project. |
| 22 | +* **Java 17** is the baseline. |
| 23 | +* Build with `mvn -B verify` (CI runs with `-DskipTests` selectively when needed). |
| 24 | + |
| 25 | +### Formatting and License Headers |
| 26 | + |
| 27 | +We use **Spotless** (Maven) to: |
| 28 | + |
| 29 | +* Format Java with **google-java-format**. |
| 30 | +* Insert/normalize **license headers** (the header content is defined **inline** in the parent POM’s `<licenseHeader>` configuration). |
| 31 | + |
| 32 | +> **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. |
| 33 | +
|
| 34 | +### Checkstyle |
| 35 | + |
| 36 | +We keep **Checkstyle** to enforce additional rules. CI fails if formatting or style checks fail. |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Developer Setup |
| 41 | + |
| 42 | +### Prerequisites |
| 43 | + |
| 44 | +* **JDK 17+** |
| 45 | +* **Maven 3.8+** |
| 46 | +* **Git** |
| 47 | +* Optional IDE plugins: |
| 48 | + |
| 49 | + * IntelliJ: *Google Java Format* plugin (for local editing experience). Spotless remains the source of truth. |
| 50 | + |
| 51 | +### Local build & formatting |
| 52 | + |
| 53 | +* Run `mvn clean install` from the repo root. During the build, Spotless **applies** formatting and license headers. |
| 54 | +* Before pushing, run `mvn -DskipTests spotless:check checkstyle:check` to ensure CI will pass. |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## Testing |
| 59 | + |
| 60 | +* **Unit tests:** `mvn -q test` or `mvn verify`. |
| 61 | +* **Integration tests (if defined):** Use the dedicated Maven profile exposed by the module, e.g. `-Pintegration-tests`. |
| 62 | +* Prefer fast, deterministic tests. Avoid time-sensitive sleeps; use time abstractions or awaitility-style utilities. |
| 63 | + |
| 64 | +### Test Guidelines |
| 65 | + |
| 66 | +* Use clear, behavior-driven names: `methodName_shouldDoX_whenY`. |
| 67 | +* Keep one logical assertion per test (or one behavior per test). |
| 68 | +* Mock only external dependencies; don’t over-mock domain logic. |
| 69 | +* Make tests independent; no ordering assumptions. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Commit & PR Guidelines |
| 74 | + |
| 75 | +### Branching |
| 76 | + |
| 77 | +* Use short, descriptive names: `fix/formatter`, `feat/http-call`, `docs/contributing`. |
| 78 | + |
| 79 | +### Commit messages |
| 80 | + |
| 81 | +* Keep messages clear and imperative: `Fix header resolution for child modules`. |
| 82 | +* Conventional Commits are welcome (`feat:`, `fix:`, `docs:`, `test:`, `refactor:`). Example: `feat: add A2A call task support`. |
| 83 | + |
| 84 | +### Pull Requests |
| 85 | + |
| 86 | +* Describe the **problem**, the **solution**, and any **trade-offs**. |
| 87 | +* Include before/after snippets or screenshots when relevant. |
| 88 | +* Link related issues. |
| 89 | +* Check the box: |
| 90 | + |
| 91 | + * [ ] `mvn -DskipTests spotless:check checkstyle:check` passes locally |
| 92 | + * [ ] Unit/integration tests updated |
| 93 | + * [ ] Public API changes documented/Javadoc updated |
| 94 | + * [ ] No unrelated formatting churn (Spotless should keep this minimal) |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Code Style & Design Notes |
| 99 | + |
| 100 | +* **Immutability first:** prefer `final` fields and defensive copies. |
| 101 | +* **Null-safety:** use `Objects.requireNonNull` at boundaries; consider `Optional` for truly optional returns (don’t use it for fields/params). |
| 102 | +* **Exceptions:** throw specific exceptions; include actionable messages; don’t swallow errors. |
| 103 | +* **Logging:** use SLF4J; no `System.out.println`; keep logs structured and at appropriate levels. |
| 104 | +* **APIs:** document with Javadoc; avoid breaking changes to public APIs unless necessary and called out in release notes. |
| 105 | +* **Generics & type-safety:** prefer precise types over `Object`; isolate unchecked casts. |
| 106 | +* **Performance:** avoid premature optimization; measure first; add micro-benchmarks (JMH) when optimizing hot paths. |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## License Headers |
| 111 | + |
| 112 | +* The license header is defined **inline** in the parent POM under Spotless’ `<licenseHeader>`. |
| 113 | +* To update it, edit the parent POM and run `mvn spotless:apply` to propagate changes. |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## CI |
| 118 | + |
| 119 | +* CI runs `spotless:check` and `checkstyle:check` to ensure consistent formatting and style. |
| 120 | +* Builds fail if formatting or headers drift. Run `mvn spotless:apply` locally to fix. |
| 121 | + |
| 122 | +--- |
| 123 | + |
| 124 | +## Troubleshooting |
| 125 | + |
| 126 | +* **Spotless changed files during build?** That’s expected locally. Review `git status`, then stage and commit the updates. |
| 127 | +* **CI red on formatting?** Run `mvn spotless:apply` locally, commit, and push. |
| 128 | +* **Running only a submodule?** Prefer `mvn -pl <module> -am …` from the repo root so parent config (Spotless/Checkstyle) is applied consistently. |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## Questions |
| 133 | + |
| 134 | +Open a discussion or issue on the repository. Thanks for contributing! 🎉 |
0 commit comments