Commit 779268b
committed
Refactor release phase to use YAML pattern instead of bash wrapper
**Problem:**
The Java buildpack was using a custom bash wrapper script
($HOME/.java-buildpack/start.sh) that sourced profile.d scripts and
executed the container command. This pattern:
- Required maintaining custom bash logic for environment setup
- Didn't follow Cloud Foundry buildpack conventions
- Made it harder to integrate with CF lifecycle hooks
**Solution:**
Adopt the standard release YAML pattern used by all reference buildpacks
(Ruby, Go, Node.js, Python):
1. **Finalize phase** writes `tmp/java-buildpack-release-step.yml` with
direct container commands (e.g., `bin/application` for DistZip,
`java -jar app.jar` for Spring Boot)
2. **Release phase** reads and outputs this YAML to stdout for Cloud
Foundry to parse
3. **Cloud Foundry runtime** handles profile.d sourcing automatically
before executing the command
**Changes:**
- src/java/finalize/cli/main.go: Added RunAfterCompile() and
SetLaunchEnvironment() lifecycle hooks
- src/java/finalize/finalize.go: Replaced generateStartupScript() with
writeReleaseYaml()
- src/java/release/release.go: Changed from hardcoded bash wrapper to
YAML passthrough
- src/java/release/release_test.go: Updated test to simulate finalize
phase creating YAML file
**Benefits:**
- Aligns with Cloud Foundry buildpack conventions
- Simplifies maintenance (no custom bash wrapper logic)
- Better integration with CF lifecycle hooks
- Profile.d scripts handled by platform (from Commit 1: 23bd35c)
**Related:**
- Depends on Commit 1 (23bd35c) which migrated environment setup to
.profile.d/*.sh scripts
- Part of 3-commit refactoring series to align with CF runtime standards1 parent 041d773 commit 779268b
File tree
4 files changed
+65
-50
lines changed- src/java
- finalize
- cli
- release
4 files changed
+65
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
239 | 231 | | |
240 | 232 | | |
241 | 233 | | |
242 | 234 | | |
243 | 235 | | |
244 | 236 | | |
245 | 237 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
270 | 249 | | |
271 | 250 | | |
272 | | - | |
273 | | - | |
274 | | - | |
| 251 | + | |
| 252 | + | |
275 | 253 | | |
276 | 254 | | |
277 | | - | |
| 255 | + | |
| 256 | + | |
278 | 257 | | |
279 | 258 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
17 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
24 | 36 | | |
25 | 37 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
| |||
0 commit comments