diff --git a/README.md b/README.md index e0f620d..89b62e4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Most users should not use this component buildpack directly and should instead u This buildpack will participate if one the following conditions are met: * `$BP_NATIVE_IMAGE` is set. -* An upstream buildpack requests `native-image-application` in the build plan. +* An upstream buildpack requests `native-image-application` in the build plan. +* An upstream buildpack provides `native-processed` in the build plan. The buildpack will do the following: diff --git a/native/detect.go b/native/detect.go index 93c992f..fe13bfe 100644 --- a/native/detect.go +++ b/native/detect.go @@ -30,6 +30,7 @@ const ( BinaryCompressionMethod = "BP_BINARY_COMPRESSION_METHOD" PlanEntryNativeImage = "native-image-application" + PlanEntryNativeProcessed = "native-processed" PlanEntryNativeImageBuilder = "native-image-builder" PlanEntryJVMApplication = "jvm-application" PlanEntrySpringBoot = "spring-boot" @@ -69,6 +70,24 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + { + Name: PlanEntryNativeImage, + }, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: PlanEntryNativeImageBuilder, + }, + { + Name: PlanEntryNativeProcessed, + }, + { + Name: PlanEntryNativeImage, + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ { @@ -93,9 +112,17 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error return libcnb.DetectResult{}, err } else if ok { for i := range result.Plans { - result.Plans[i].Requires = append(result.Plans[i].Requires, libcnb.BuildPlanRequire{ - Name: PlanEntryNativeImage, - }) + found := false + for _, r := range result.Plans[i].Requires { + if r.Name == PlanEntryNativeImage { + found = true + } + } + if !found { + result.Plans[i].Requires = append(result.Plans[i].Requires, libcnb.BuildPlanRequire{ + Name: PlanEntryNativeImage, + }) + } } } diff --git a/native/detect_test.go b/native/detect_test.go index a694ece..c37f782 100644 --- a/native/detect_test.go +++ b/native/detect_test.go @@ -58,6 +58,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -112,6 +128,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -165,6 +197,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -246,6 +294,25 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + { + Name: "upx", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -305,6 +372,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -361,6 +444,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -417,6 +516,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"}, @@ -474,6 +589,22 @@ func testDetect(t *testing.T, context spec.G, it spec.S) { }, }, }, + { + Provides: []libcnb.BuildPlanProvide{ + {Name: "native-image-application"}, + }, + Requires: []libcnb.BuildPlanRequire{ + { + Name: "native-image-builder", + }, + { + Name: "native-processed", + }, + { + Name: "native-image-application", + }, + }, + }, { Provides: []libcnb.BuildPlanProvide{ {Name: "native-image-application"},