$npx -y skills add AdamBien/airails --skill zbBuild Java 25+ projects with zb (Zero Dependencies Builder). Use when compiling, building, packaging, or running Java projects that have no external dependencies. Triggers on "build with zb", "zb build", "compile and package", "create executable JAR", or when a .zb configuration
| 1 | # zb - Zero Dependencies Builder |
| 2 | |
| 3 | Build single-module Java 25+ projects into executable JARs without Maven or Gradle. |
| 4 | |
| 5 | ## How to Build |
| 6 | |
| 7 | ### Step 1: Check for zb.sh script |
| 8 | |
| 9 | Search for a `zb.sh` wrapper script in this order — stop at the first match: |
| 10 | |
| 11 | 1. `zb.sh` in the project root |
| 12 | 2. Glob for `**/zb.sh` within the project directory tree |
| 13 | 3. Glob for `**/zb.sh` one level above the project (sibling projects) |
| 14 | 4. Check `~/bin/zb.sh` or `~/.local/bin/zb.sh` |
| 15 | |
| 16 | **If `zb.sh` is found**, skip to Step 3 (zb.sh) — the script handles jar location and execution internally. |
| 17 | |
| 18 | **If `zb.sh` is not found**, continue to Step 2 to locate `zb.jar` manually. |
| 19 | |
| 20 | ### Step 2: Find zb.jar (only if zb.sh not found) |
| 21 | |
| 22 | Locate `zb.jar` in this order — stop at the first match: |
| 23 | |
| 24 | 1. `zb.jar` in the project root |
| 25 | 2. Glob for `**/zb.jar` within the project directory tree |
| 26 | 3. Glob for `**/zb.jar` one level above the project (sibling projects) |
| 27 | 4. Check `~/bin/zb.jar` or `~/.local/bin/zb.jar` |
| 28 | |
| 29 | If neither `zb.sh` nor `zb.jar` is found, tell the user to download from [github.com/AdamBien/zb](https://github.com/AdamBien/zb). |
| 30 | |
| 31 | ### Step 3: Find the build directory |
| 32 | |
| 33 | zb must run from the directory containing the `.zb` config file (or where one should be generated). In multi-module repos, this is the module subdirectory, not the repo root. |
| 34 | |
| 35 | - Glob for `.zb` files in the project |
| 36 | - `cd` into the directory containing the `.zb` file before running zb |
| 37 | - If no `.zb` exists, run from the directory that contains `src/main/java` |
| 38 | |
| 39 | ### Step 4: Run the build |
| 40 | |
| 41 | **With zb.sh:** |
| 42 | |
| 43 | ```bash |
| 44 | cd <build-directory> && <path-to-zb.sh> |
| 45 | ``` |
| 46 | |
| 47 | **With zb.jar (fallback):** |
| 48 | |
| 49 | ```bash |
| 50 | cd <build-directory> && java -jar <path-to-zb.jar> |
| 51 | ``` |
| 52 | |
| 53 | ### Step 5: Verify |
| 54 | |
| 55 | Check exit code and output. A successful build prints the number of compiled files. Common errors: |
| 56 | - **"Multiple main classes found"** — you are in the wrong directory (likely the repo root instead of a module subdirectory) |
| 57 | - **Compilation errors** — fix the source and rebuild |
| 58 | |
| 59 | ## Source Directory Convention |
| 60 | |
| 61 | zb auto-detects sources in order: |
| 62 | |
| 63 | 1. `src/main/java` (Maven convention, preferred) |
| 64 | 2. `src/` |
| 65 | 3. Current directory `.` |
| 66 | |
| 67 | Resources auto-detected from `src/main/resources` or current directory. |
| 68 | |
| 69 | ## Entry Point Requirement |
| 70 | |
| 71 | The project must have exactly one class with a `void main(` method (Java 25+ unnamed main). |
| 72 | |
| 73 | ## Configuration (.zb) |
| 74 | |
| 75 | Optional `.zb` properties file in the build directory (auto-generated on first run): |
| 76 | |
| 77 | ```properties |
| 78 | sources.dir=<discovered by zb> |
| 79 | resources.dir=<discovered by zb> |
| 80 | classes.dir=<temp.dir> |
| 81 | jar.dir=zbo/ |
| 82 | jar.file.name=app.jar |
| 83 | ``` |
| 84 | |
| 85 | - `<discovered by zb>` — auto-detect directory |
| 86 | - `<temp.dir>` — use temporary directory, cleaned after build |
| 87 | |
| 88 | ## CLI Arguments (Positional) |
| 89 | |
| 90 | ```bash |
| 91 | java -jar zb.jar [sources] [classes] [jar_dir] [jar_file] |
| 92 | ``` |
| 93 | |
| 94 | Precedence: CLI args > `.zb` file > defaults. |
| 95 | |
| 96 | ## Output |
| 97 | |
| 98 | Default: `zbo/app.jar` — executable JAR with Main-Class manifest entry. |
| 99 | |
| 100 | Run with: |
| 101 | |
| 102 | ```bash |
| 103 | java -jar zbo/app.jar |
| 104 | ``` |
| 105 | |
| 106 | ## Constraints |
| 107 | |
| 108 | - Java 25+ required |
| 109 | - No external dependency support (no Maven/Gradle dependency resolution) |
| 110 | - Single-module projects only |
| 111 | - Exactly one main class per project |
| 112 | |
| 113 | ## After a Successful Build |
| 114 | |
| 115 | If the project has a `test/` directory containing `*Test.java` files, ask the user if they want to run tests with `/zunit`. |