[camel-k] branch master updated: fix for wrong pom generation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel-k] branch master updated: fix for wrong pom generation

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 21db7f0  fix for wrong pom generation
21db7f0 is described below

commit 21db7f0cb490ba71255e94cf31f6b6677df69ced
Author: lburgazzoli <[hidden email]>
AuthorDate: Mon Feb 11 15:12:07 2019 +0100

    fix for wrong pom generation
---
 pkg/builder/builder.go              |  1 +
 pkg/builder/builder_steps.go        |  7 ++++++-
 pkg/builder/builder_steps_test.go   |  3 +++
 pkg/builder/builder_types.go        |  1 +
 pkg/builder/builder_utils.go        | 18 +++++++++++++++---
 pkg/builder/springboot/generator.go |  7 ++++++-
 6 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go
index bfde547..7f88f70 100644
--- a/pkg/builder/builder.go
+++ b/pkg/builder/builder.go
@@ -177,6 +177,7 @@ func (b *defaultBuilder) process(request Request, handler func(*Result)) {
 
  c := Context{
  Client:    b.client,
+ Catalog:   request.Catalog,
  Path:      builderPath,
  Namespace: b.namespace,
  Request:   request,
diff --git a/pkg/builder/builder_steps.go b/pkg/builder/builder_steps.go
index e607965..ecc16fe 100644
--- a/pkg/builder/builder_steps.go
+++ b/pkg/builder/builder_steps.go
@@ -41,7 +41,12 @@ import (
 
 // GenerateProject --
 func GenerateProject(ctx *Context) error {
- ctx.Project = NewProject(ctx)
+ p, err := NewProject(ctx)
+ if err != nil {
+ return err
+ }
+
+ ctx.Project = p
 
  //
  // Repositories
diff --git a/pkg/builder/builder_steps_test.go b/pkg/builder/builder_steps_test.go
index 896835b..f884384 100644
--- a/pkg/builder/builder_steps_test.go
+++ b/pkg/builder/builder_steps_test.go
@@ -35,6 +35,7 @@ func TestGenerateJvmProject(t *testing.T) {
  assert.Nil(t, err)
 
  ctx := Context{
+ Catalog: catalog,
  Request: Request{
  Catalog: catalog,
  Platform: v1alpha1.IntegrationPlatformSpec{
@@ -78,6 +79,7 @@ func TestGenerateGroovyProject(t *testing.T) {
  assert.Nil(t, err)
 
  ctx := Context{
+ Catalog: catalog,
  Request: Request{
  Catalog: catalog,
  Platform: v1alpha1.IntegrationPlatformSpec{
@@ -132,6 +134,7 @@ func TestGenerateProjectWithRepositories(t *testing.T) {
  assert.Nil(t, err)
 
  ctx := Context{
+ Catalog: catalog,
  Request: Request{
  Catalog: catalog,
  Platform: v1alpha1.IntegrationPlatformSpec{
diff --git a/pkg/builder/builder_types.go b/pkg/builder/builder_types.go
index f10d2ee..c7a4e5b 100644
--- a/pkg/builder/builder_types.go
+++ b/pkg/builder/builder_types.go
@@ -143,6 +143,7 @@ type Result struct {
 // Context --
 type Context struct {
  client.Client
+ Catalog           *camel.RuntimeCatalog
  Request           Request
  BaseImage         string
  Image             string
diff --git a/pkg/builder/builder_utils.go b/pkg/builder/builder_utils.go
index 493728b..1d0cfce 100644
--- a/pkg/builder/builder_utils.go
+++ b/pkg/builder/builder_utils.go
@@ -20,6 +20,7 @@ package builder
 import (
  "encoding/xml"
 
+ "github.com/apache/camel-k/pkg/util/camel"
  "github.com/apache/camel-k/pkg/util/maven"
  "github.com/apache/camel-k/version"
 
@@ -38,8 +39,17 @@ func ArtifactIDs(artifacts []v1alpha1.Artifact) []string {
 }
 
 // NewProject --
-func NewProject(ctx *Context) maven.Project {
- return maven.Project{
+func NewProject(ctx *Context) (maven.Project, error) {
+ if ctx.Catalog == nil {
+ c, err := camel.Catalog(ctx.Request.C, ctx.Client, ctx.Namespace, ctx.Request.Platform.Build.CamelVersion)
+ if err != nil {
+ return maven.Project{}, err
+ }
+
+ ctx.Catalog = c
+ }
+
+ p := maven.Project{
  XMLName:           xml.Name{Local: "project"},
  XMLNs:             "http://maven.apache.org/POM/4.0.0",
  XMLNsXsi:          "http://www.w3.org/2001/XMLSchema-instance",
@@ -54,7 +64,7 @@ func NewProject(ctx *Context) maven.Project {
  {
  GroupID:    "org.apache.camel",
  ArtifactID: "camel-bom",
- Version:    ctx.Request.Platform.Build.CamelVersion,
+ Version:    ctx.Catalog.Version,
  Type:       "pom",
  Scope:      "import",
  },
@@ -62,4 +72,6 @@ func NewProject(ctx *Context) maven.Project {
  },
  Dependencies: make([]maven.Dependency, 0),
  }
+
+ return p, nil
 }
diff --git a/pkg/builder/springboot/generator.go b/pkg/builder/springboot/generator.go
index d0954db..6a7a77c 100644
--- a/pkg/builder/springboot/generator.go
+++ b/pkg/builder/springboot/generator.go
@@ -28,7 +28,12 @@ import (
 
 // GenerateProject --
 func GenerateProject(ctx *builder.Context) error {
- ctx.Project = builder.NewProject(ctx)
+ p, err := builder.NewProject(ctx)
+ if err != nil {
+ return err
+ }
+
+ ctx.Project = p
 
  //
  // Repositories