You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a 'How it works' section (Detect/Supply/Finalize/Runtime) describing the
java_cf_env framework, and document how to limit the automatic behaviour:
JBP_CONFIG_JAVA_CF_ENV '{enabled: false}' disables the whole framework, and —
since the buildpack backs off when the app bundles its own java-cfenv*.jar — an
app can bundle java-cfenv-boot (props, no cloud profile) or java-cfenv core
(neither) to scope it.
Refs #1349.
Copy file name to clipboardExpand all lines: docs/framework-java-cfenv.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,15 @@ The buildpack selects the appropriate `java-cfenv` version based on the detected
25
25
</table>
26
26
Tags are printed to standard output by the buildpack detect script
27
27
28
+
## How it works
29
+
30
+
The framework is implemented in `src/java/frameworks/java_cf_env.go`:
31
+
32
+
1.**Detect** — activates only when all of these hold: the framework is enabled (see [Configuration](#configuration)); a Spring Boot 3.x or 4.x marker is found (a `spring-boot-{3,4}.*.jar` under `BOOT-INF/lib`, `WEB-INF/lib`, or `lib/`, or a `Spring-Boot-Version: 3.*` / `4.*` entry in `META-INF/MANIFEST.MF`); and the application does not already bundle a `java-cfenv*.jar` (if it does, the buildpack backs off and uses the application's own copy).
33
+
2.**Supply** — selects the java-cfenv version from the detected Spring Boot major (Spring Boot 3 → the manifest's `3.x` line, Spring Boot 4 → the `4.x` line) and installs the `java-cfenv-all` jar into the dependency directory.
34
+
3.**Finalize** — appends the installed jar to `CLASSPATH` via a `.profile.d/java_cf_env.sh` script, so it is on the application's runtime classpath.
35
+
4.**Runtime** — Spring Boot reads the jar's `META-INF/spring.factories`: the `EnvironmentPostProcessor`s map `VCAP_SERVICES` to Spring properties, and `CloudProfileApplicationListener` (in the `java-cfenv-all` module) activates the `cloud` profile when running in Cloud Foundry.
36
+
28
37
## Configuration
29
38
30
39
The framework can be disabled via the `JBP_CONFIG_JAVA_CF_ENV` environment variable:
@@ -53,3 +62,16 @@ Disable when:
53
62
- The application handles `VCAP_SERVICES` manually with custom binding logic
54
63
- The automatic `cloud` profile activation is unwanted
55
64
- Another service binding library conflicts with `java-cfenv`
65
+
66
+
`{enabled: false}` disables the **whole** framework — both the `VCAP_SERVICES` → Spring property mapping and the `cloud` profile activation. There is no option to disable only the `cloud` profile.
67
+
68
+
For finer control, bundle a java-cfenv artifact in the application yourself. Because the buildpack backs off whenever a `java-cfenv*.jar` is already present, the app's choice wins:
|`java-cfenv-all`| yes | yes (app pins the version) |
74
+
|`java-cfenv-boot`| yes |**no** (no `CloudProfileApplicationListener`) |
75
+
|`java-cfenv` (core) |**no** (API only) |**no**|
76
+
77
+
So an app can include `java-cfenv-boot` to keep property mapping without the `cloud` profile, or the bare `java-cfenv` core to opt out of all automatic behaviour and use the `CfEnv` API directly.
0 commit comments