MCPcopy Index your code
hub / github.com/cloudfoundry/java-buildpack

github.com/cloudfoundry/java-buildpack @v5.0.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.0.5 ↗ · + Follow
820 symbols 2,803 edges 143 files 597 documented · 73%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cloud Foundry Java Buildpack

The java-buildpack is a [Cloud Foundry][] buildpack for running JVM-based applications. It is designed to run many JVM-based applications ([Grails][], [Groovy][], Java Main, [Play Framework][], [Spring Boot][], and Servlet) with no additional configuration, but supports configuration of the standard components, and extension to add custom components.

Usage

To use this buildpack specify the URI of the repository when pushing an application to Cloud Foundry:

$ cf push <APP-NAME> -p <ARTIFACT> -b https://github.com/cloudfoundry/java-buildpack.git

Examples

The following are very simple examples for deploying the artifact types that we support.

Configuration and Extension

The buildpack default configuration can be overridden with an environment variable matching the configuration file you wish to override minus the .yml extension. It is not possible to add new configuration properties and properties with nil or empty values will be ignored by the buildpack (in this case you will have to extend the buildpack, see below). The value of the variable should be valid inline yaml, referred to as "flow style" in the yaml spec ([Wikipedia][] has a good description of this yaml syntax).

There are two levels of overrides: operator and application developer.

  • If you are an operator that wishes to override configuration across a foundation, you may do this by setting environment variable group entries that begin with a prefix of JBP_DEFAULT.
  • If you are an application developer that wishes to override configuration for an individual application, you may do this by setting environment variables that begin with a prefix of JBP_CONFIG.

Here are some examples:

Operator

  1. To change the default version of Java to 11 across all applications on a foundation.
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_OPEN_JDK_JRE":"{jre: {version: 11.+ }}"}'
  1. To change the default repository root across all applications on a foundation. Be careful to ensure that your JSON is properly escaped.
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_REPOSITORY": "{default_repository_root: \"http://repo.example.io\" }"}'
  1. DEPRECATED: To change the default JVM vendor across all applications on a foundation, use JRE-specific environment variables instead. JBP_CONFIG_COMPONENTS for JRE selection is no longer supported in the Go buildpack.
# Use this instead
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_ZULU_JRE":"{jre: {version: 17.+ }}"}'

Application Developer

  1. To change the default version of Java to 11 and adjust the memory heuristics then apply this environment variable to the application.
$ cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ jre: { version: 11.+ }, memory_calculator: { stack_threads: 25 } }'
  1. If the key or value contains a special character such as : it should be escaped with double quotes. For example, to change the default repository path for the buildpack.
$ cf set-env my-application JBP_CONFIG_REPOSITORY '{ default_repository_root: "http://repo.example.io" }'
  1. If the key or value contains an environment variable that you want to bind at runtime you need to escape it from your shell. For example, to add command line arguments containing an environment variable to a Java Main application.
$ cf set-env my-application JBP_CONFIG_JAVA_MAIN '{ arguments: "--server.port=9090 --foo=bar" }'
  1. An example of configuration is to specify a javaagent that is packaged within an application.
$ cf set-env my-application JAVA_OPTS '-javaagent:app/META-INF/myagent.jar -Dmyagent.config_file=app/META-INF/my_agent.conf'
  1. Environment variable can also be specified in the applications manifest file. For example, to specify an environment variable in an applications manifest file that disables Auto-reconfiguration.
env:
  JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{ enabled: false }'
  1. This final example shows how to change the version of Tomcat that is used by the buildpack with an environment variable specified in the applications manifest file.
env:
  JBP_CONFIG_TOMCAT: '{ tomcat: { version: 8.0.+ } }'

See the [Environment Variables][] documentation for more information.

JRE Selection

Important: The Go buildpack does NOT support JBP_CONFIG_COMPONENTS for JRE selection (this differs from the Ruby buildpack). This environment variable is deprecated in favor of using JRE-specific configuration variables.

To select a different JRE, use the appropriate JBP_CONFIG_<JRE_NAME> variable:

# Switch to SapMachine JRE
$ cf set-env my-app JBP_CONFIG_SAP_MACHINE_JRE '{ jre: { version: 17.+ }}'

# Switch to Zulu JRE
$ cf set-env my-app JBP_CONFIG_ZULU_JRE '{ jre: { version: 21.+ }}'

# For BYOL JREs (Oracle, GraalVM, IBM, Zing), you must first add them to manifest.yml
# See https://github.com/cloudfoundry/java-buildpack/blob/main/docs/custom-jre-usage.md

The buildpack will automatically detect and use the configured JRE without requiring JBP_CONFIG_COMPONENTS.

See the [Environment Variables][] documentation for more information.

To learn how to configure various properties of the buildpack, follow the "Configuration" links below.

The buildpack supports extension through the use of Git repository forking. The easiest way to accomplish this is to use [GitHub's forking functionality][] to create a copy of this repository. Make the required extension changes in the copy of the repository. Then specify the URL of the new repository when pushing Cloud Foundry applications. If the modifications are generally applicable to the Cloud Foundry community, please submit a [pull request][] with the changes. More information on extending the buildpack is available here.

Ruby vs Go Migration Status

This Go-based buildpack is a migration from the original Ruby-based Cloud Foundry Java Buildpack. For comprehensive information about the migration status, component parity, and architectural differences:

⚠️ Important Migration Note: The Go buildpack does NOT support the Ruby buildpack's repository_root configuration approach for custom JREs (via JBP_CONFIG_* environment variables). Custom JREs now require forking the buildpack and modifying manifest.yml. See Custom JRE Usage for details.

Quick Status Summary (as of December 16, 2025): - ✅ All 8 container types implemented (100%) - ✅ All 7 JRE providers implemented (3 in manifest + 4 BYOL via custom manifest) - ✅ 37 of 40 frameworks implemented (92.5%) - ✅ All integration tests passing - ⚠️ Only 3 missing frameworks are niche/deprecated (affecting <2% of applications) - 📝 BYOL JREs (GraalVM, IBM, Oracle, Zing) require custom manifest - see Custom JRE Usage

For historical analysis documents from development sessions, see docs/archive/.

Additional Documentation

Extension points exported contracts — how you extend this code

DependencyIdentifierProvider (Interface)
Framework represents a cross-cutting concern (APM agents, security providers, etc.) DependencyIdentifierProvider optiona [26 …
src/java/frameworks/framework.go
Container (Interface)
Container represents a Java application container (Tomcat, Spring Boot, etc.) [7 implementers]
src/java/containers/container.go
Framework (Interface)
(no doc) [44 implementers]
src/java/frameworks/framework.go
Component (Interface)
Component represents a JRE component (memory calculator, jvmkill, etc.) [4 implementers]
src/java/jres/jre.go
JRE (Interface)
JRE represents a Java Runtime Environment provider [2 implementers]
src/java/jres/jre.go

Core symbols most depended-on inside this repo

Finalize
called by 310
src/java/frameworks/framework.go
Detect
called by 222
src/java/frameworks/framework.go
Execute
called by 119
src/java/common/context.go
DepDir
called by 119
src/java/common/context.go
Detect
called by 70
src/java/containers/container.go
Name
called by 64
src/java/jres/jre.go
BuildDir
called by 63
src/java/common/context.go
DefaultVersion
called by 54
src/java/common/context.go

Shape

Method 481
Function 217
Struct 107
Interface 9
Class 5
TypeAlias 1

Languages

Go98%
Java2%

Modules by API surface

src/internal/mocks/mocks.go46 symbols
src/java/common/context.go32 symbols
src/java/jres/jre.go28 symbols
src/java/containers/tomcat.go25 symbols
src/java/frameworks/luna_security_provider.go22 symbols
src/java/jres/memory_calculator.go19 symbols
src/java/containers/play.go18 symbols
src/java/frameworks/java_memory_assistant.go16 symbols
src/java/frameworks/framework.go16 symbols
src/java/containers/spring_boot.go16 symbols
src/java/frameworks/container_security_provider.go14 symbols
src/java/containers/java_main.go14 symbols

Datastores touched

(mysql)Database · 1 repos
(mongodb)Database · 1 repos
dbDatabase · 1 repos
mydbDatabase · 1 repos
dbDatabase · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add java-buildpack \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact