Skip to content

Commit

Permalink
Fix spring-boot#481: add JRE_HOME
Browse files Browse the repository at this point in the history
* JRE_HOME is often used as a convention to convey the path of a JRE; in this case it's convenient to distinguish the JRE from a JDK (when both are required), since the PATH can insert the JRE_HOME/bin or JDK_HOME/bin in a non predictable order.
* Thanks to JRE_HOME, subsequent build steps will be able to use JRE_HOME/bin/java to make sure they pick a JRE and not a JDK
* in case there's just a JDK desired by the user, JRE_HOME will also be set, as the JDK_HOME
  • Loading branch information
anthonydahanne committed May 22, 2024
1 parent a4ac4f2 commit 0fa5ddf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions jre.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (j JRE) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {

if IsBuildContribution(j.Metadata) {
layer.BuildEnvironment.Default("JAVA_HOME", layer.Path)
layer.BuildEnvironment.Default("JRE_HOME", layer.Path)
}

if IsLaunchContribution(j.Metadata) {
Expand Down
1 change: 1 addition & 0 deletions jre_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func testJRE(t *testing.T, context spec.G, it spec.S) {
Expect(layer.LayerTypes.Build).To(BeTrue())
Expect(layer.LayerTypes.Cache).To(BeTrue())
Expect(layer.BuildEnvironment["JAVA_HOME.default"]).To(Equal(layer.Path))
Expect(layer.BuildEnvironment["JRE_HOME.default"]).To(Equal(layer.Path))
})

it("marks before Java 9 JRE layer for launch", func() {
Expand Down

0 comments on commit 0fa5ddf

Please sign in to comment.