Skip to content

Commit

Permalink
Merge pull request #68 from paketo-buildpacks/jvm-application-package
Browse files Browse the repository at this point in the history
Require jvm-application-package in build plan
  • Loading branch information
ekcasey authored Mar 10, 2021
2 parents 52c72b8 + 6dd6bf8 commit f74fe6f
Showing 2 changed files with 49 additions and 27 deletions.
16 changes: 13 additions & 3 deletions tomcat/detect.go
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ import (
"github.com/paketo-buildpacks/libjvm"
)

const (
PlanEntryJVMApplication = "jvm-application"
PlanEntryJVMApplicationPackage = "jvm-application-package"
PlanEntryJRE = "jre"
)

type Detect struct{}

func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
@@ -41,9 +47,13 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
Pass: true,
Plans: []libcnb.BuildPlan{
{
Provides: []libcnb.BuildPlanProvide{
{Name: PlanEntryJVMApplication},
},
Requires: []libcnb.BuildPlanRequire{
{Name: "jre", Metadata: map[string]interface{}{"launch": true}},
{Name: "jvm-application"},
{Name: PlanEntryJRE, Metadata: map[string]interface{}{"launch": true}},
{Name: PlanEntryJVMApplicationPackage},
{Name: PlanEntryJVMApplication},
},
},
},
@@ -56,6 +66,6 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
return result, nil
}

result.Plans[0].Provides = append(result.Plans[0].Provides, libcnb.BuildPlanProvide{Name: "jvm-application"})
result.Plans[0].Provides = append(result.Plans[0].Provides, libcnb.BuildPlanProvide{Name: PlanEntryJVMApplicationPackage})
return result, nil
}
60 changes: 36 additions & 24 deletions tomcat/detect_test.go
Original file line number Diff line number Diff line change
@@ -57,36 +57,48 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{Pass: false}))
})

it("passes without WEB-INF", func() {
Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{
Pass: true,
Plans: []libcnb.BuildPlan{
{
Requires: []libcnb.BuildPlanRequire{
{Name: "jre", Metadata: map[string]interface{}{"launch": true}},
{Name: "jvm-application"},
context("WEB-INF not found", func() {
it("requires jvm-application-artifact", func() {
Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{
Pass: true,
Plans: []libcnb.BuildPlan{
{
Provides: []libcnb.BuildPlanProvide{
{Name: "jvm-application"},
},
Requires: []libcnb.BuildPlanRequire{
{Name: "jre", Metadata: map[string]interface{}{"launch": true}},
{Name: "jvm-application-package"},
{Name: "jvm-application"},
},
},
},
},
}))
}))
})
})

it("passes with WEB-INF", func() {
Expect(os.MkdirAll(filepath.Join(path, "WEB-INF"), 0755)).To(Succeed())
context("WEB-INF found", func() {
it.Before(func() {
Expect(os.MkdirAll(filepath.Join(path, "WEB-INF"), 0755)).To(Succeed())
})

Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{
Pass: true,
Plans: []libcnb.BuildPlan{
{
Provides: []libcnb.BuildPlanProvide{
{Name: "jvm-application"},
},
Requires: []libcnb.BuildPlanRequire{
{Name: "jre", Metadata: map[string]interface{}{"launch": true}},
{Name: "jvm-application"},
it("requires and provides jvm-application-artifact", func() {
Expect(detect.Detect(ctx)).To(Equal(libcnb.DetectResult{
Pass: true,
Plans: []libcnb.BuildPlan{
{
Provides: []libcnb.BuildPlanProvide{
{Name: "jvm-application"},
{Name: "jvm-application-package"},
},
Requires: []libcnb.BuildPlanRequire{
{Name: "jre", Metadata: map[string]interface{}{"launch": true}},
{Name: "jvm-application-package"},
{Name: "jvm-application"},
},
},
},
},
}))
}))
})
})
}

0 comments on commit f74fe6f

Please sign in to comment.