Skip to content

Commit 2a4eca1

Browse files
authored
Merge pull request #1134 from cloudfoundry/fix-jruby-openjdk-cflinuxfs5
Add cflinuxfs5 JVM support via new openjdk dependency naming - fix jruby test
2 parents 336bc0e + b7df03c commit 2a4eca1

4 files changed

Lines changed: 53 additions & 3 deletions

File tree

manifest.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,16 @@ dependencies:
9797
cf_stacks:
9898
- cflinuxfs3
9999
- cflinuxfs4
100-
- cflinuxfs5
101100
source: https://java-buildpack.cloudfoundry.org/openjdk-jdk/bionic/x86_64/openjdk-jdk-1.8.0_242-bionic.tar.gz
102101
source_sha256: dcb9fea2fc3a9b003031874ed17aa5d5a7ebbe397b276ecc8c814633003928fe
102+
- name: openjdk
103+
version: 17.0.13
104+
uri: https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jre_x64_linux_hotspot_17.0.13_11.tar.gz
105+
sha256: 4086cc7cb2d9e7810141f255063caad10a8a018db5e6b47fa5394c506ab65bff
106+
cf_stacks:
107+
- cflinuxfs5
108+
source: https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.13%2B11/OpenJDK17U-jre_x64_linux_hotspot_17.0.13_11.tar.gz
109+
source_sha256: 4086cc7cb2d9e7810141f255063caad10a8a018db5e6b47fa5394c506ab65bff
103110
- name: ruby
104111
version: 3.2.8
105112
uri: https://buildpacks.cloudfoundry.org/dependencies/ruby/ruby_3.2.8_linux_x64_cflinuxfs3_f36a7c8d.tgz

src/ruby/supply/mocks_test.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ruby/supply/supply.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Manifest interface {
3030
type Installer interface {
3131
InstallDependency(libbuildpack.Dependency, string) error
3232
InstallOnlyVersion(string, string) error
33+
InstallOnlyVersionWithStrip(string, string, int) error
3334
}
3435

3536
type Versions interface {
@@ -386,8 +387,17 @@ func (s *Supplier) InstallJVM() error {
386387
}
387388

388389
jvmInstallDir := filepath.Join(s.Stager.DepDir(), "jvm")
389-
if err := s.Installer.InstallOnlyVersion("openjdk1.8-latest", jvmInstallDir); err != nil {
390-
return err
390+
if len(s.Manifest.AllDependencyVersions("openjdk")) > 0 {
391+
// New naming used in cflinuxfs5: openjdk with semantic version (8.x, 17.x, 21.x,…)
392+
// BellSoft Liberica / Temurin tarballs have a top-level jdk-XX/ directory, strip it.
393+
if err := s.Installer.InstallOnlyVersionWithStrip("openjdk", jvmInstallDir, 1); err != nil {
394+
return err
395+
}
396+
} else {
397+
// Legacy naming used in cflinuxfs3/4: flat tarball, no strip needed.
398+
if err := s.Installer.InstallOnlyVersion("openjdk1.8-latest", jvmInstallDir); err != nil {
399+
return err
400+
}
391401
}
392402
if err := s.Stager.LinkDirectoryInDepDir(filepath.Join(jvmInstallDir, "bin"), "bin"); err != nil {
393403
return err

src/ruby/supply/supply_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ var _ = Describe("Supply", func() {
605605

606606
Context("app/.jdk does not exist", func() {
607607
BeforeEach(func() {
608+
mockManifest.EXPECT().AllDependencyVersions("openjdk").Return([]string{})
608609
mockInstaller.EXPECT().InstallOnlyVersion("openjdk1.8-latest", gomock.Any()).Do(func(_, path string) error {
609610
Expect(os.MkdirAll(filepath.Join(path, "bin"), 0755)).To(Succeed())
610611
Expect(os.WriteFile(filepath.Join(path, "bin", "java"), []byte("java.exe"), 0755)).To(Succeed())
@@ -625,6 +626,24 @@ var _ = Describe("Supply", func() {
625626
Expect(string(body)).To(ContainSubstring(`export JAVA_MEM=${JAVA_MEM:--Xmx${JVM_MAX_HEAP:-384}m}`))
626627
})
627628
})
629+
630+
Context("app/.jdk does not exist and openjdk (new naming) is available", func() {
631+
BeforeEach(func() {
632+
// Override the global AllDependencyVersions("openjdk") mock for this context
633+
mockManifest.EXPECT().AllDependencyVersions("openjdk").Return([]string{"17.0.13"}).AnyTimes()
634+
mockInstaller.EXPECT().InstallOnlyVersionWithStrip("openjdk", gomock.Any(), 1).Do(func(_, path string, _ int) error {
635+
Expect(os.MkdirAll(filepath.Join(path, "bin"), 0755)).To(Succeed())
636+
Expect(os.WriteFile(filepath.Join(path, "bin", "java"), []byte("java.exe"), 0755)).To(Succeed())
637+
return nil
638+
})
639+
})
640+
641+
It("installs and links the JDK using new openjdk naming (cflinuxfs5)", func() {
642+
Expect(supplier.InstallJVM()).To(Succeed())
643+
Expect(filepath.Join(depsDir, depsIdx, "jvm", "bin", "java")).To(BeAnExistingFile())
644+
Expect(filepath.Join(depsDir, depsIdx, "bin", "java")).To(BeAnExistingFile())
645+
})
646+
})
628647
})
629648

630649
Describe("EnableLDLibraryPathEnv", func() {

0 commit comments

Comments
 (0)