Skip to content

Commit

Permalink
fix(trait): deprecate old native profile
Browse files Browse the repository at this point in the history
Closes #6021
  • Loading branch information
squakez committed Jan 16, 2025
1 parent 3b7523a commit 4c04907
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
11 changes: 3 additions & 8 deletions pkg/builder/runtime_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ func (n *NativeSourcesAdapter) NativeMavenProperty() string {
}

// NativeAdapter used for Camel Quarkus runtime < 3.5.0.
// Deprecated: use NativeSourcesAdapter instead.
type NativeAdapter struct {
}

// BuildCommands -- .
func (n *NativeAdapter) BuildCommands() string {
// We must override the local repo as it's not shared from the builder container
return "cd " + n.Directory() + " && ./mvnw $(cat MAVEN_CONTEXT) package -Dquarkus.native.enabled=true -Dmaven.repo.local=./repo"
return "cd " + n.Directory() + " && ./mvnw $(cat MAVEN_CONTEXT) package -Dmaven.repo.local=./repo"
}

// Directory -- .
Expand All @@ -79,17 +80,11 @@ func (n *NativeAdapter) TargetDirectory(ctxPath, runner string) string {

// NativeMavenProperty -- .
func (n *NativeAdapter) NativeMavenProperty() string {
// Empty on purpose. The parameter will be provided later by the command (see BuildCommands()).
// Empty on purpose.
return ""
}

// QuarkusRuntimeSupport is used to get the proper native configuration based on the Camel Quarkus version.
func QuarkusRuntimeSupport(version string) QuarkusRuntimeNativeAdapter {
// Version 3.6.0 depends on a parameter which is available on JDK-21 based image.
// For this reason we fallback to the "legacy" Quarkus native build.
// Hopefully this will be solved starting from runtime version 3.7.0.
if version < "3.7.0" {
return &NativeAdapter{}
}
return &NativeSourcesAdapter{}
}
2 changes: 1 addition & 1 deletion pkg/trait/jvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (t *jvmTrait) enableDebug(e *Environment) string {
if meta.Labels == nil {
meta.Labels = make(map[string]string)
}
meta.Labels["camel.apache.org/debug"] = "true"
meta.Labels["camel.apache.org/debug"] = trueString
})
t.DebugAddress = "*:5005"

Expand Down
11 changes: 6 additions & 5 deletions pkg/trait/quarkus.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,14 @@ func (t *quarkusTrait) applyWhenBuildSubmitted(e *Environment) error {

//nolint:nestif
if native {
buildTask.Maven.Properties["quarkus.native.enabled"] = "true"
if nativePackageType := builder.QuarkusRuntimeSupport(e.CamelCatalog.GetCamelQuarkusVersion()).NativeMavenProperty(); nativePackageType != "" {
buildTask.Maven.Properties[nativePackageType] = "true"
if t.NativeBaseImage == "" {
packageTask.BaseImage = QuarkusNativeDefaultBaseImageName
} else {
packageTask.BaseImage = t.NativeBaseImage
}
}
if t.NativeBaseImage == "" {
packageTask.BaseImage = QuarkusNativeDefaultBaseImageName
} else {
packageTask.BaseImage = t.NativeBaseImage
}
if len(e.IntegrationKit.Spec.Sources) > 0 {
buildTask.Sources = e.IntegrationKit.Spec.Sources
Expand Down

0 comments on commit 4c04907

Please sign in to comment.