camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nferr...@apache.org
Subject [camel-k] 03/07: maven: cleanup build process
Date Thu, 20 Sep 2018 21:05:23 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 99493ddf9b5a840b4d054c65b4e1568b754ef9da
Author: lburgazzoli <lburgazzoli@gmail.com>
AuthorDate: Thu Sep 20 12:30:48 2018 +0200

    maven: cleanup build process
---
 deploy/platform-integration-context-core.yaml   |  2 +-
 deploy/platform-integration-context-groovy.yaml |  2 +-
 deploy/resources.go                             |  4 +-
 pkg/build/local/local_builder.go                |  2 +-
 pkg/stub/action/integration/deploy.go           | 18 +--------
 pkg/util/maven/maven.go                         | 50 +++++++++++--------------
 tmp/build/Dockerfile                            |  2 +-
 7 files changed, 29 insertions(+), 51 deletions(-)

diff --git a/deploy/platform-integration-context-core.yaml b/deploy/platform-integration-context-core.yaml
index 3fe794c..d0d3289 100644
--- a/deploy/platform-integration-context-core.yaml
+++ b/deploy/platform-integration-context-core.yaml
@@ -1,7 +1,7 @@
 apiVersion: camel.apache.org/v1alpha1
 kind: IntegrationContext
 metadata:
-  name: core.integrationcontexts.camel.apache.org
+  name: core
   labels:
     app: "camel-k"
     camel.apache.org/context.created.by.kind: Operator
diff --git a/deploy/platform-integration-context-groovy.yaml b/deploy/platform-integration-context-groovy.yaml
index 5c5cbf4..e1c327c 100644
--- a/deploy/platform-integration-context-groovy.yaml
+++ b/deploy/platform-integration-context-groovy.yaml
@@ -1,7 +1,7 @@
 apiVersion: camel.apache.org/v1alpha1
 kind: IntegrationContext
 metadata:
-  name: groovy.integrationcontexts.camel.apache.org
+  name: groovy
   labels:
     app: "camel-k"
     camel.apache.org/context.created.by.kind: Operator
diff --git a/deploy/resources.go b/deploy/resources.go
index ec79a89..f4e9210 100644
--- a/deploy/resources.go
+++ b/deploy/resources.go
@@ -2441,7 +2441,7 @@ status:
 apiVersion: camel.apache.org/v1alpha1
 kind: IntegrationContext
 metadata:
-  name: core.integrationcontexts.camel.apache.org
+  name: core
   labels:
     app: "camel-k"
     camel.apache.org/context.created.by.kind: Operator
@@ -2456,7 +2456,7 @@ spec:
 apiVersion: camel.apache.org/v1alpha1
 kind: IntegrationContext
 metadata:
-  name: groovy.integrationcontexts.camel.apache.org
+  name: groovy
   labels:
     app: "camel-k"
     camel.apache.org/context.created.by.kind: Operator
diff --git a/pkg/build/local/local_builder.go b/pkg/build/local/local_builder.go
index 2bb59ce..364c244 100644
--- a/pkg/build/local/local_builder.go
+++ b/pkg/build/local/local_builder.go
@@ -153,7 +153,7 @@ func (b *localBuilder) publish(tarFile string, source *build.Request)
(string, e
 					SourceStrategy: &buildv1.SourceBuildStrategy{
 						From: v1.ObjectReference{
 							Kind: "DockerImage",
-							Name: "fabric8/s2i-java:2.1",
+							Name: "fabric8/s2i-java:2.3",
 						},
 					},
 				},
diff --git a/pkg/stub/action/integration/deploy.go b/pkg/stub/action/integration/deploy.go
index c6ba592..b3bce77 100644
--- a/pkg/stub/action/integration/deploy.go
+++ b/pkg/stub/action/integration/deploy.go
@@ -19,11 +19,8 @@ package action
 
 import (
 	"fmt"
-	"os"
 	"strings"
 
-	"github.com/apache/camel-k/version"
-
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
 	"github.com/operator-framework/operator-sdk/pkg/sdk"
 	"github.com/pkg/errors"
@@ -77,12 +74,6 @@ func getConfigMapFor(ctx *v1alpha1.IntegrationContext, integration *v1alpha1.Int
 	// combine properties of integration with context, integration
 	// properties have the priority
 	properties := CombineConfigurationAsMap("property", ctx, integration)
-	classpath := make([]string, 0, len(ctx.Spec.Classpath))
-
-	//TODO: we need some constants
-	for _, path := range ctx.Spec.Classpath {
-		classpath = append(classpath, strings.Replace(path, "/tmp/artifacts/m2", "/deployments/m2",
1))
-	}
 
 	cm := corev1.ConfigMap{
 		TypeMeta: metav1.TypeMeta{
@@ -111,7 +102,6 @@ func getConfigMapFor(ctx *v1alpha1.IntegrationContext, integration *v1alpha1.Int
 		Data: map[string]string{
 			"integration": integration.Spec.Source.Content,
 			"properties":  PropertiesString(properties),
-			"classpath":   strings.Join(classpath, string(os.PathListSeparator)),
 		},
 	}
 
@@ -152,11 +142,8 @@ func getDeploymentFor(ctx *v1alpha1.IntegrationContext, integration *v1alpha1.In
 
 	// set env vars needed by the runtime
 	environment["JAVA_MAIN_CLASS"] = "org.apache.camel.k.jvm.Application"
-	environment["JAVA_LIB_DIR"] = "/etc/camel/conf"
-
-	//TODO: remove this hack !!! s2i java (/opt/run-java/run-java.sh) fails if JAVA_APP_JAR
is not set
-	environment["JAVA_APP_JAR"] = fmt.Sprintf("/deployments/m2/org/apache/camel/k/camel-k-runtime-jvm/%s/camel-k-runtime-jvm-%s.jar",
version.Version, version.Version)
 
+	// camel-k runtime
 	environment["CAMEL_K_ROUTES_URI"] = "file:/etc/camel/conf/" + sourceName
 	environment["CAMEL_K_ROUTES_LANGUAGE"] = string(integration.Spec.Source.Language)
 	environment["CAMEL_K_CONF"] = "/etc/camel/conf/application.properties"
@@ -241,9 +228,6 @@ func getDeploymentFor(ctx *v1alpha1.IntegrationContext, integration *v1alpha1.In
 					}, {
 						Key:  "properties",
 						Path: "application.properties",
-					}, {
-						Key:  "classpath",
-						Path: "classpath",
 					},
 				},
 			},
diff --git a/pkg/util/maven/maven.go b/pkg/util/maven/maven.go
index 8f67982..d008162 100644
--- a/pkg/util/maven/maven.go
+++ b/pkg/util/maven/maven.go
@@ -125,20 +125,28 @@ func createTar(project Project, result *BuildResult) (string, error)
{
 	writer := tar.NewWriter(tarFile)
 	defer writer.Close()
 
-	for _, path := range result.Classpath {
-		err = appendToTarWithPath(path, writer)
+	cp := ""
+	for _, filePath := range result.Classpath {
+		fileName, err := appendFileToTar(filePath, "dependencies", writer)
 		if err != nil {
 			return "", err
 		}
+
+		cp += fileName + "\n"
+	}
+
+	err = appendDataToTar([]byte(cp), "classpath", writer)
+	if err != nil {
+		return "", err
 	}
 
 	return tarFileName, nil
 }
 
-func appendToTar(filePath string, tarPath string, writer *tar.Writer) error {
+func appendFileToTar(filePath string, tarPath string, writer *tar.Writer) (string, error)
{
 	info, err := os.Stat(filePath)
 	if err != nil {
-		return err
+		return "", err
 	}
 	_, fileName := path.Split(filePath)
 	if tarPath != "" {
@@ -154,42 +162,28 @@ func appendToTar(filePath string, tarPath string, writer *tar.Writer)
error {
 
 	file, err := os.Open(filePath)
 	if err != nil {
-		return err
+		return "", err
 	}
 	defer file.Close()
 
 	_, err = io.Copy(writer, file)
 	if err != nil {
-		return errors.Wrap(err, "cannot add file to the tar archive")
-	}
-	return nil
-}
-
-func appendToTarWithPath(path string, writer *tar.Writer) error {
-	info, err := os.Stat(path)
-	if err != nil {
-		return err
+		return "", errors.Wrap(err, "cannot add file to the tar archive")
 	}
 
-	//TODO: we ned some constants
-	relocatedPath := strings.TrimPrefix(path, "/tmp/artifacts")
+	return fileName, nil
+}
 
+func appendDataToTar(data []byte, tarPath string, writer *tar.Writer) error {
 	writer.WriteHeader(&tar.Header{
-		Name:    relocatedPath,
-		Size:    info.Size(),
-		Mode:    int64(info.Mode()),
-		ModTime: info.ModTime(),
+		Name: tarPath,
+		Size: int64(len(data)),
+		Mode: 0644,
 	})
 
-	file, err := os.Open(path)
-	if err != nil {
-		return err
-	}
-	defer file.Close()
-
-	_, err = io.Copy(writer, file)
+	_, err := writer.Write(data)
 	if err != nil {
-		return errors.Wrap(err, "cannot add file to the tar archive")
+		return errors.Wrap(err, "cannot add data to the tar archive")
 	}
 	return nil
 }
diff --git a/tmp/build/Dockerfile b/tmp/build/Dockerfile
index df1abde..cbd151d 100644
--- a/tmp/build/Dockerfile
+++ b/tmp/build/Dockerfile
@@ -1,4 +1,4 @@
-FROM fabric8/s2i-java:2.1
+FROM fabric8/s2i-java:2.3
 
 #RUN adduser -D camel-k-operator
 #USER camel-k-operator


Mime
View raw message