You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/01/16 11:23:44 UTC
(camel-k) branch main updated: Execute Quarkus JVM mode before native mode
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 0feccdb3d Execute Quarkus JVM mode before native mode
0feccdb3d is described below
commit 0feccdb3dc09e4aece7990d4f7c4ecb6b4649f4c
Author: Michal Vavřík <mv...@redhat.com>
AuthorDate: Mon Jan 15 23:18:30 2024 +0100
Execute Quarkus JVM mode before native mode
---
pkg/trait/quarkus.go | 4 ++++
pkg/trait/quarkus_test.go | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 8027436fa..cb8b216f0 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -210,6 +210,10 @@ func (t *quarkusTrait) applyWhileBuildingKit(e *Environment) {
kit := t.newIntegrationKit(e, packageType(t.Modes[0]))
e.IntegrationKits = append(e.IntegrationKits, *kit)
default:
+ // execute jvm mode before native mode
+ sort.Slice(t.Modes, func(i, j int) bool {
+ return t.Modes[i] != traitv1.NativeQuarkusMode
+ })
for _, md := range t.Modes {
kit := t.newIntegrationKit(e, packageType(md))
if kit.Spec.Traits.Quarkus == nil {
diff --git a/pkg/trait/quarkus_test.go b/pkg/trait/quarkus_test.go
index 4b9312c0b..d92481167 100644
--- a/pkg/trait/quarkus_test.go
+++ b/pkg/trait/quarkus_test.go
@@ -20,6 +20,8 @@ package trait
import (
"testing"
+ traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
+
"github.com/stretchr/testify/assert"
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
@@ -84,6 +86,24 @@ func TestApplyQuarkusTraitAnnotationKitConfiguration(t *testing.T) {
}
+func TestQuarkusTraitBuildModeOrder(t *testing.T) {
+ quarkusTrait, environment := createNominalQuarkusTest()
+ quarkusTrait.Modes = []traitv1.QuarkusMode{traitv1.NativeQuarkusMode, traitv1.JvmQuarkusMode}
+ environment.Integration.Status.Phase = v1.IntegrationPhaseBuildingKit
+ environment.Integration.Spec.Sources = []v1.SourceSpec{
+ {
+ Language: v1.LanguageYaml,
+ },
+ }
+
+ err := quarkusTrait.Apply(environment)
+ assert.Nil(t, err)
+ assert.Len(t, environment.IntegrationKits, 2)
+ // assure jvm mode is executed before native mode
+ assert.Equal(t, environment.IntegrationKits[0].Labels[v1.IntegrationKitLayoutLabel], v1.IntegrationKitLayoutFastJar)
+ assert.Equal(t, environment.IntegrationKits[1].Labels[v1.IntegrationKitLayoutLabel], v1.IntegrationKitLayoutNativeSources)
+}
+
func createNominalQuarkusTest() (*quarkusTrait, *Environment) {
trait, _ := newQuarkusTrait().(*quarkusTrait)
client, _ := test.NewFakeClient()