Skip to content

Commit dc5f179

Browse files
committed
Add cflinuxfs5 JVM support via new openjdk dependency naming
1 parent 4d0d1af commit dc5f179

5 files changed

Lines changed: 58 additions & 5 deletions

File tree

manifest.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ dependencies:
9999
- cflinuxfs4
100100
source: https://java-buildpack.cloudfoundry.org/openjdk-jdk/bionic/x86_64/openjdk-jdk-1.8.0_242-bionic.tar.gz
101101
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
102110
- name: ruby
103111
version: 3.2.8
104112
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() {

src/ruby/versions/ruby.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (v *Versions) GetBundlerVersion() (string, error) {
5858
return "", err
5959
}
6060

61-
re := regexp.MustCompile(`Bundler version (\d+\.\d+\.\d+) .*`)
61+
re := regexp.MustCompile(`(?:Bundler version )?(\d+\.\d+\.\d+) .*`)
6262
match := re.FindStringSubmatch(stdout.String())
6363

6464
if len(match) != 2 {
@@ -191,9 +191,11 @@ func (v *Versions) GemMajorVersion(gem string) (int, error) {
191191
}
192192
}
193193

194-
//Should return true if either:
194+
// Should return true if either:
195195
// (1) the only platform in the Gemfile.lock is windows (mingw/mswin)
196-
// -or-
196+
//
197+
// -or-
198+
//
197199
// (2) the Gemfile.lock line endings are /r/n, rather than just /n
198200
func (v *Versions) HasWindowsGemfileLock() (bool, error) {
199201
gemfileLockPath := v.Gemfile() + ".lock"

0 commit comments

Comments
 (0)