|
1 | 1 | # spawn |
| 2 | +A Java framework for programmatically launching and controlling processes, JVMs, and Docker containers. |
2 | 3 |
|
3 | | -build.spawn: A framework to programmatically launch and control processes, applications, services and containers |
| 4 | +[](https://github.com/Workday/spawn.build/actions/workflows/main-pull-request.yml) |
| 5 | +[](https://central.sonatype.com/artifact/build.spawn/spawn-application) |
| 6 | +[](LICENSE) |
4 | 7 |
|
5 | | -When using this framework to launch Docker containers, the following JVM command-line argument must be added |
6 | | -(with Java 25+): |
| 8 | +## Overview |
7 | 9 |
|
8 | | -```bash |
9 | | - --enable-native-access=ALL-UNNAMED |
| 10 | +`spawn` provides a unified abstraction over local processes, JVMs, and Docker containers. Define a |
| 11 | +`Specification`, call `platform.launch(spec)`, and get back an `Application` with |
| 12 | +`CompletableFuture`-based lifecycle hooks — regardless of the underlying execution environment. |
| 13 | + |
| 14 | +## Modules |
| 15 | + |
| 16 | +| Module | Purpose | |
| 17 | +|--------|---------| |
| 18 | +| `spawn-option` | Shared option types | |
| 19 | +| `spawn-application` | Core abstractions: Platform, Application, Process, Specification, Customizer | |
| 20 | +| `spawn-application-composition` | Multi-application topology management | |
| 21 | +| `spawn-jdk` | JDK launch abstractions and SpawnAgent for two-way JVM communication | |
| 22 | +| `spawn-local-platform` | Local OS process launcher (`LocalMachine`) | |
| 23 | +| `spawn-local-jdk` | JDK detection and `LocalJDKLauncher` | |
| 24 | +| `spawn-docker` | Docker Engine API interfaces | |
| 25 | +| `spawn-docker-jdk` | JDK HTTP Client-based Docker implementation | |
| 26 | + |
| 27 | +## Requirements |
| 28 | + |
| 29 | +- Java 25+ |
| 30 | +- Maven (wrapper included — no separate install needed) |
| 31 | +- Docker (only required for `spawn-docker` / `spawn-docker-jdk` modules) |
| 32 | + |
| 33 | +## Using this Library |
| 34 | + |
| 35 | +Add individual modules as dependencies. All modules share the same version: |
| 36 | + |
| 37 | +```xml |
| 38 | +<dependency> |
| 39 | + <groupId>build.spawn</groupId> |
| 40 | + <artifactId>spawn-application</artifactId> |
| 41 | + <version>VERSION</version> |
| 42 | +</dependency> |
10 | 43 | ``` |
11 | 44 |
|
12 | | -On MacOS (and linux), local machine access to the Docker Engine may be restricted to prevent read and write access to |
13 | | -the docker.socket. To ensure access to the Docker Engine, the permissions for the following files may need to be |
14 | | -increase. |
| 45 | +Replace `VERSION` with the latest version shown in the Maven Central badge above. |
| 46 | + |
| 47 | +When using the Docker modules, add the following JVM flag (Java 25+): |
15 | 48 |
|
16 | 49 | ``` |
17 | | -sudo chmod 660 ~/Library/Containers/com.docker.docker/Data/docker.raw.sock |
| 50 | +--enable-native-access=ALL-UNNAMED |
18 | 51 | ``` |
19 | 52 |
|
20 | | -and |
| 53 | +On macOS and Linux, access to the Docker socket may require a permissions adjustment: |
21 | 54 |
|
22 | | -``` |
| 55 | +```bash |
| 56 | +sudo chmod 660 ~/Library/Containers/com.docker.docker/Data/docker.raw.sock |
23 | 57 | sudo chmod 660 /var/run/docker.sock |
24 | 58 | ``` |
25 | 59 |
|
26 | | -It's also possible that the symbolic link to `/var/run/docker.sock` may need to be recreated. |
| 60 | +If `/var/run/docker.sock` is missing, recreate the symlink: |
27 | 61 |
|
28 | | -``` |
| 62 | +```bash |
29 | 63 | sudo ln -s ~/Library/Containers/com.docker.docker/Data/docker.raw.sock /var/run/docker.sock |
30 | 64 | ``` |
31 | 65 |
|
32 | | -## Running Tests |
| 66 | +## Building from Source |
33 | 67 |
|
34 | | -The Docker integration tests (`SessionTests`) require several images to be present in the local Docker cache before running. |
| 68 | +```bash |
| 69 | +./mvnw clean install |
| 70 | +``` |
35 | 71 |
|
36 | | -Pre-pull them once using: |
| 72 | +To build a custom version: |
| 73 | + |
| 74 | +```bash |
| 75 | +./mvnw -Drevision=x.y.z-SNAPSHOT-my-name clean install |
| 76 | +``` |
| 77 | + |
| 78 | +### Running Tests |
| 79 | + |
| 80 | +Docker integration tests require several images to be present in the local cache. Pre-pull them once before running: |
37 | 81 |
|
38 | 82 | ```bash |
39 | 83 | docker pull alpine:latest && docker pull rabbitmq:latest && docker pull nginx:latest |
40 | 84 | ``` |
41 | 85 |
|
42 | | -Without this step, the test setup (`@BeforeAll`) will attempt to pull these images on demand, which blocks the tests |
43 | | -for several minutes and may fail due to transient registry (timeout) errors. |
| 86 | +## Contributing |
| 87 | + |
| 88 | +Code style is enforced by Checkstyle: no tabs, no star imports, final locals and parameters, braces |
| 89 | +required on all blocks, no `assert` statements. Import order: third-party, standard Java, then |
| 90 | +static. IntelliJ configuration is at `config/intellij/CodeStyle.xml`. |
| 91 | + |
| 92 | +Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/). |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +Apache 2.0 — see [LICENSE](LICENSE) |
0 commit comments