Skip to content

Commit

Permalink
Merge branch 'main' into update/pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dmikusa authored Oct 27, 2022
2 parents 6278164 + 8c9c6f8 commit 51b636a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
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())
})
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/buildpacks/libcnb v1.27.0
github.com/heroku/color v0.0.6
github.com/magiconair/properties v1.8.6
github.com/onsi/gomega v1.22.1
github.com/onsi/gomega v1.23.0
github.com/paketo-buildpacks/libjvm v1.40.0
github.com/paketo-buildpacks/libpak v1.63.0
github.com/pelletier/go-toml v1.9.5
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ github.com/buildpacks/libcnb v1.27.0/go.mod h1:SZirCtDl+AiFHTS6R4KlUPMqWzjwmEACs
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -28,9 +29,9 @@ github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebG
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/onsi/ginkgo/v2 v2.3.0 h1:kUMoxMoQG3ogk/QWyKh3zibV7BKZ+xBpWil1cTylVqc=
github.com/onsi/gomega v1.22.1 h1:pY8O4lBfsHKZHM/6nrxkhVPUznOlIu3quZcKP/M20KI=
github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM=
github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs=
github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys=
github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
github.com/paketo-buildpacks/libjvm v1.40.0 h1:LP/Phi8oI9pLV4aT81cSejwXggqvyLJN2YxV4lbfagg=
github.com/paketo-buildpacks/libjvm v1.40.0/go.mod h1:K8K0BsOUGBFwF4jQiKzXH9dMnftkT1wO/BV67mBoUkE=
github.com/paketo-buildpacks/libpak v1.63.0 h1:LLBKp3QNXzpSIrz54dZqvxtZawFzZon69d7HGof2eKw=
Expand Down

0 comments on commit 51b636a

Please sign in to comment.