Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boot/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
}
classpathLayer.Logger = b.Logger
result.Layers = append(result.Layers, classpathLayer)

} else {
// contribute Spring Cloud Bindings - false by default
if !cr.ResolveBool("BP_SPRING_CLOUD_BINDINGS_DISABLED") {
Expand Down
10 changes: 10 additions & 0 deletions boot/native_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package boot

import (
"fmt"
"github.com/paketo-buildpacks/libpak/sherpa"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -65,6 +66,15 @@ func (n NativeImageClasspath) Contribute(layer libcnb.Layer) (libcnb.Layer, erro
string(filepath.ListSeparator),
strings.Join(cp, string(filepath.ListSeparator)),
)

nativeImageArgFile := filepath.Join(n.ApplicationPath, "META-INF", "native-image", "argfile")
if exists, err := sherpa.Exists(nativeImageArgFile); err != nil{
return libcnb.Layer{}, fmt.Errorf("unable to check for native-image arguments file at %s\n%w", nativeImageArgFile, err)
} else if exists{
lc.Logger.Bodyf(fmt.Sprintf("native args file %s", nativeImageArgFile))
layer.BuildEnvironment.Default("BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE", nativeImageArgFile)
}

return layer, nil
})
}
Expand Down
20 changes: 20 additions & 0 deletions boot/native_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,24 @@ func testNativeImage(t *testing.T, context spec.G, it spec.S) {
Expect(layer.LayerTypes.Launch).To(BeFalse())
})
})
context("Boot @argfile is found", func() {
it.Before(func() {
Expect(ioutil.WriteFile(filepath.Join(appDir, "BOOT-INF", "classpath.idx"), []byte(`
- "some.jar"
- "other.jar"
`), 0644)).To(Succeed())
Expect(os.MkdirAll(filepath.Join(appDir, "META-INF", "native-image"), 0755)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(appDir, "META-INF", "native-image", "argfile"), []byte("file-data"), 0644)).To(Succeed())
})

it("ensures BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE is set when argfile is found", func() {
layer, err := contributor.Contribute(layer)
Expect(err).NotTo(HaveOccurred())

Expect(layer.BuildEnvironment["BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE.default"]).To(Equal(
filepath.Join(appDir, "META-INF", "native-image", "argfile")))
Expect(layer.LayerTypes.Build).To(BeTrue())
Expect(layer.LayerTypes.Launch).To(BeFalse())
})
})
}