|
| 1 | +# io.klib Bootstrap — OSGi Workspace |
| 2 | + |
| 3 | +This directory contains the [bnd](https://bnd.bndtools.org/) Gradle workspace for the |
| 4 | +`io.klib.bootstrap` OSGi application. It uses **Java 21** and is built with the |
| 5 | +**Gradle 8.13** wrapper included in this folder. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +| Tool | Version | Notes | |
| 12 | +|------|---------|-------| |
| 13 | +| Java JDK | 21+ | Gradle will auto-provision via toolchain if not found | |
| 14 | +| (Optional) Eclipse IDE | 2024-12+ | Import with [BNDTools 7+](https://bndtools.org/) plug-in | |
| 15 | + |
| 16 | +> No Maven or `bnd` CLI installation is required — everything runs through `./gradlew`. |
| 17 | +
|
| 18 | +--- |
| 19 | + |
| 20 | +## Project structure |
| 21 | + |
| 22 | +``` |
| 23 | +osgi/ ← bnd workspace root (_root Eclipse project) |
| 24 | +├── cnf/ ← workspace configuration (Eclipse project: cnf) |
| 25 | +│ ├── build.bnd ← workspace-wide bnd settings (Java 21, version, etc.) |
| 26 | +│ ├── ext/ |
| 27 | +│ │ ├── repositories.bnd ← repository plug-in definitions |
| 28 | +│ │ └── junit5.bnd ← JUnit 5 / osgi-test BSN macro variables |
| 29 | +│ └── pom.xml ← Maven Central artifact list for BndPomRepository |
| 30 | +├── io.klib.bootstrap.api/ ← public service interfaces + ProvisionResult record |
| 31 | +├── io.klib.bootstrap.core/ ← DS @Component implementations + unit tests |
| 32 | +├── io.klib.bootstrap.app/ ← application launcher bndrun files |
| 33 | +│ ├── launch.bndrun ← production launcher (Felix + SCR + bundles) |
| 34 | +│ └── debug.bndrun ← debug launcher (adds Gogo shell, -runtrace) |
| 35 | +├── io.klib.bootstrap.test.integration/ ← OSGi integration tests (osgi-test) |
| 36 | +│ └── integration.bndrun ← integration test launcher |
| 37 | +├── build.gradle ← workspace root Gradle build |
| 38 | +├── settings.gradle ← Gradle settings (bnd workspace plug-in) |
| 39 | +├── gradlew / gradlew.bat ← Gradle 8.13 wrapper scripts |
| 40 | +└── README.md ← this file |
| 41 | +``` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## Building |
| 46 | + |
| 47 | +```bash |
| 48 | +# From the osgi/ directory: |
| 49 | +cd osgi |
| 50 | + |
| 51 | +# Full workspace build (compile + unit tests + OSGi integration tests) |
| 52 | +./gradlew build |
| 53 | + |
| 54 | +# Compile only |
| 55 | +./gradlew assemble |
| 56 | + |
| 57 | +# Run only unit tests (io.klib.bootstrap.core) |
| 58 | +./gradlew test |
| 59 | + |
| 60 | +# Run only OSGi integration tests |
| 61 | +./gradlew :io.klib.bootstrap.test.integration:testOSGi |
| 62 | +``` |
| 63 | + |
| 64 | +> **Tip:** On Windows, replace `./gradlew` with `gradlew.bat`. |
| 65 | +
|
| 66 | +--- |
| 67 | + |
| 68 | +## Running the application |
| 69 | + |
| 70 | +The application is launched via the `io.klib.bootstrap.app` bndrun files. |
| 71 | + |
| 72 | +### Production launch |
| 73 | + |
| 74 | +```bash |
| 75 | +# Gradle task (recommended) |
| 76 | +./gradlew :io.klib.bootstrap.app:run.launch |
| 77 | + |
| 78 | +# Export a self-contained runnable JAR/directory first, then launch it |
| 79 | +./gradlew :io.klib.bootstrap.app:export.launch |
| 80 | +``` |
| 81 | + |
| 82 | +### Debug launch (with Felix Gogo interactive shell) |
| 83 | + |
| 84 | +```bash |
| 85 | +./gradlew :io.klib.bootstrap.app:run.debug |
| 86 | +``` |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## Running the tests |
| 91 | + |
| 92 | +### JUnit 5 unit tests (no OSGi framework required) |
| 93 | + |
| 94 | +```bash |
| 95 | +./gradlew :io.klib.bootstrap.core:test |
| 96 | +``` |
| 97 | + |
| 98 | +### OSGi integration tests (full Felix container) |
| 99 | + |
| 100 | +```bash |
| 101 | +./gradlew :io.klib.bootstrap.test.integration:testOSGi |
| 102 | +``` |
| 103 | + |
| 104 | +Test reports are written to: |
| 105 | + |
| 106 | +``` |
| 107 | +io.klib.bootstrap.test.integration/generated/test-reports/testOSGi/ |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## Re-resolving bndrun files |
| 113 | + |
| 114 | +The `-runbundles` list in each `.bndrun` file is pre-resolved and committed. |
| 115 | +If you add new `-runrequires` entries or change dependency versions, re-resolve with: |
| 116 | + |
| 117 | +```bash |
| 118 | +# Resolve launch.bndrun |
| 119 | +./gradlew :io.klib.bootstrap.app:resolve.launch |
| 120 | + |
| 121 | +# Resolve debug.bndrun |
| 122 | +./gradlew :io.klib.bootstrap.app:resolve.debug |
| 123 | + |
| 124 | +# Resolve integration.bndrun |
| 125 | +./gradlew :io.klib.bootstrap.test.integration:resolve |
| 126 | +``` |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Importing into Eclipse with BNDTools |
| 131 | + |
| 132 | +1. Install **Eclipse IDE for Java Developers** (2024-12 or later). |
| 133 | +2. Install the **BNDTools** plug-in via the Eclipse Marketplace. |
| 134 | +3. In Eclipse: **File → Import → Existing Projects into Workspace**. |
| 135 | +4. Set the root directory to this `osgi/` folder. |
| 136 | +5. Select **all** projects found (including `_root` and `cnf`). |
| 137 | +6. Click **Finish**. |
| 138 | + |
| 139 | +Eclipse will resolve the workspace dependencies automatically via the |
| 140 | +`BndPomRepository` configuration in `cnf/ext/repositories.bnd`. |
| 141 | + |
| 142 | +> The `_root` project is configured with resource filters so that the Eclipse |
| 143 | +> Project Explorer shows only workspace-level files (`build.gradle`, |
| 144 | +> `settings.gradle`, `gradlew`, …) while hiding the bundle sub-project |
| 145 | +> directories that are already visible as separate Eclipse projects. |
| 146 | +
|
| 147 | +--- |
| 148 | + |
| 149 | +## Key version numbers |
| 150 | + |
| 151 | +| Component | Version | |
| 152 | +|-----------|---------| |
| 153 | +| Java | 21 | |
| 154 | +| Gradle wrapper | 8.13 | |
| 155 | +| bnd / BNDTools | 7.1.0 | |
| 156 | +| Apache Felix Framework | 7.0.5 | |
| 157 | +| Apache Felix SCR | 2.2.6 | |
| 158 | +| JUnit 5 | 5.11.4 | |
| 159 | +| osgi-test | 1.3.0 | |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## License |
| 164 | + |
| 165 | +[MIT](https://opensource.org/licenses/MIT) — © klibio contributors |
0 commit comments