You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/06/02 06:39:52 UTC

[camel-k] 01/03: fix #2327: Honor maven-repository flag in the run command

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit f13ebec127dba728f84adec06fe6e90e91cefb53
Author: John Poth <po...@gmail.com>
AuthorDate: Tue May 25 16:31:15 2021 +0200

    fix #2327: Honor maven-repository flag in the run command
---
 config/crd/bases/camel.apache.org_builds.yaml | 4 ++++
 helm/camel-k/crds/crd-build.yaml              | 4 ++++
 pkg/apis/camel/v1/common_types.go             | 3 ++-
 pkg/apis/camel/v1/zz_generated.deepcopy.go    | 5 +++++
 pkg/builder/quarkus.go                        | 5 +++++
 pkg/trait/builder.go                          | 7 ++++++-
 6 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml
index 09b377e..fcc09a8 100644
--- a/config/crd/bases/camel.apache.org_builds.yaml
+++ b/config/crd/bases/camel.apache.org_builds.yaml
@@ -162,6 +162,10 @@ spec:
                                 type: string
                               description: The Maven properties.
                               type: object
+                            repositories:
+                              items:
+                                type: string
+                              type: array
                             settings:
                               description: A reference to the ConfigMap or Secret
                                 key that contains the Maven settings.
diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml
index 09b377e..fcc09a8 100644
--- a/helm/camel-k/crds/crd-build.yaml
+++ b/helm/camel-k/crds/crd-build.yaml
@@ -162,6 +162,10 @@ spec:
                                 type: string
                               description: The Maven properties.
                               type: object
+                            repositories:
+                              items:
+                                type: string
+                              type: array
                             settings:
                               description: A reference to the ConfigMap or Secret
                                 key that contains the Maven settings.
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index ac83542..430a6e3 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -103,7 +103,8 @@ type MavenSpec struct {
 	// Note that the root CA certificates are also imported into the created keystore.
 	CASecret *corev1.SecretKeySelector `json:"caSecret,omitempty"`
 	// Deprecated: use IntegrationPlatform.Spec.Build.Timeout instead
-	Timeout *metav1.Duration `json:"timeout,omitempty"`
+	Timeout      *metav1.Duration `json:"timeout,omitempty"`
+	Repositories []string         `json:"repositories,omitempty"`
 }
 
 // ValueSource --
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index 270d0fe..4a1a040 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -1272,6 +1272,11 @@ func (in *MavenSpec) DeepCopyInto(out *MavenSpec) {
 		*out = new(metav1.Duration)
 		**out = **in
 	}
+	if in.Repositories != nil {
+		in, out := &in.Repositories, &out.Repositories
+		*out = make([]string, len(*in))
+		copy(*out, *in)
+	}
 }
 
 // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MavenSpec.
diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go
index 4678be5..0b4651d 100644
--- a/pkg/builder/quarkus.go
+++ b/pkg/builder/quarkus.go
@@ -81,6 +81,11 @@ func generateQuarkusProject(ctx *builderContext) error {
 	// Add all the properties from the build configuration
 	p.Properties.AddAll(ctx.Build.Maven.Properties)
 
+	// Add Maven repositories
+	for _, repo := range ctx.Build.Maven.Repositories {
+		p.Repositories = append(p.Repositories, maven.NewRepository(repo))
+	}
+
 	ctx.Maven.Project = p
 
 	return nil
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index ba8e26f..959fccd 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -134,13 +134,18 @@ func (t *builderTrait) Apply(e *Environment) error {
 }
 
 func (t *builderTrait) builderTask(e *Environment) (*v1.BuilderTask, error) {
+	maven := e.Platform.Status.Build.Maven
+
+	// Add Maven repositories defined in the IntergrationKit
+	maven.Repositories = append(maven.Repositories, e.IntegrationKit.Spec.Repositories...)
+
 	task := &v1.BuilderTask{
 		BaseTask: v1.BaseTask{
 			Name: "builder",
 		},
 		Runtime:      e.CamelCatalog.Runtime,
 		Dependencies: e.IntegrationKit.Spec.Dependencies,
-		Maven:        e.Platform.Status.Build.Maven,
+		Maven:        maven,
 	}
 
 	if task.Maven.Properties == nil {