You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2019/05/14 14:27:52 UTC

[camel-k] branch master updated: remove spring boot support #534

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


The following commit(s) were added to refs/heads/master by this push:
     new b11b4f3  remove spring boot support #534
b11b4f3 is described below

commit b11b4f39ec2acd662aece568ab357415b870c896
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Tue May 14 10:47:27 2019 +0200

    remove spring boot support #534
---
 cmd/builder/main.go                      |   1 -
 pkg/builder/springboot/dependencies.go   |  45 ----------
 pkg/builder/springboot/generator.go      | 137 -------------------------------
 pkg/builder/springboot/generator_test.go |  90 --------------------
 pkg/builder/springboot/initializer.go    |  40 ---------
 pkg/builder/springboot/springboot.go     |  47 -----------
 pkg/trait/springboot.go                  | 123 ---------------------------
 pkg/trait/trait_catalog.go               |   6 --
 test/builder_integration_test.go         |   1 -
 9 files changed, 490 deletions(-)

diff --git a/cmd/builder/main.go b/cmd/builder/main.go
index 9c79700..2a20e0e 100644
--- a/cmd/builder/main.go
+++ b/cmd/builder/main.go
@@ -33,7 +33,6 @@ import (
 	"github.com/apache/camel-k/pkg/builder"
 	_ "github.com/apache/camel-k/pkg/builder/kaniko"
 	_ "github.com/apache/camel-k/pkg/builder/s2i"
-	_ "github.com/apache/camel-k/pkg/builder/springboot"
 	"github.com/apache/camel-k/pkg/client"
 	util "github.com/apache/camel-k/pkg/controller/build"
 	"github.com/apache/camel-k/pkg/util/cancellable"
diff --git a/pkg/builder/springboot/dependencies.go b/pkg/builder/springboot/dependencies.go
deleted file mode 100644
index 876465a..0000000
--- a/pkg/builder/springboot/dependencies.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package springboot
-
-import (
-	"path"
-	"strings"
-
-	"github.com/apache/camel-k/pkg/builder"
-	"github.com/apache/camel-k/pkg/util/maven"
-)
-
-func computeDependencies(ctx *builder.Context) error {
-	for i := 0; i < len(ctx.Artifacts); i++ {
-		if strings.HasPrefix(ctx.Artifacts[i].ID, "org.apache.camel.k:camel-k-runtime-spring-boot:") {
-
-			_, fileName := path.Split(ctx.Artifacts[i].Location)
-			gav, err := maven.ParseGAV(ctx.Artifacts[i].ID)
-			if err != nil {
-				return nil
-			}
-
-			// Don't set a target so the jar will be copied to the
-			// deployment root
-			ctx.Artifacts[i].Target = gav.GroupID + "." + fileName
-		}
-	}
-
-	return nil
-}
diff --git a/pkg/builder/springboot/generator.go b/pkg/builder/springboot/generator.go
deleted file mode 100644
index d1d7af3..0000000
--- a/pkg/builder/springboot/generator.go
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package springboot
-
-import (
-	"fmt"
-	"strings"
-
-	"github.com/apache/camel-k/pkg/builder"
-	"github.com/apache/camel-k/pkg/util/maven"
-)
-
-func generateProject(ctx *builder.Context) error {
-	p, err := builder.NewProject(ctx)
-	if err != nil {
-		return err
-	}
-
-	ctx.Project = p
-	//
-	// set-up dependencies
-	//
-	ctx.Project.AddDependency(maven.Dependency{
-		GroupID:    "org.apache.camel.k",
-		ArtifactID: "camel-k-runtime-spring-boot",
-		Version:    ctx.Build.RuntimeVersion,
-		Exclusions: &[]maven.Exclusion{
-			{
-				GroupID:    "org.apache.camel",
-				ArtifactID: "*",
-			},
-			{
-				GroupID:    "org.apache.camel.k",
-				ArtifactID: "*",
-			},
-			{
-				GroupID:    "org.springframework.boot",
-				ArtifactID: "*",
-			},
-		},
-	})
-
-	//
-	// others
-	//
-
-	for _, d := range ctx.Build.Dependencies {
-		switch {
-		case strings.HasPrefix(d, "camel:"):
-			if d == "camel:core" {
-				continue
-			}
-
-			artifactID := strings.TrimPrefix(d, "camel:")
-
-			if !strings.HasPrefix(artifactID, "camel-") {
-				artifactID = "camel-" + artifactID
-			}
-
-			ctx.Project.AddDependency(maven.Dependency{
-				GroupID:    "org.apache.camel",
-				ArtifactID: artifactID + "-starter",
-				Version:    ctx.Catalog.Version,
-				Exclusions: &[]maven.Exclusion{
-					{
-						GroupID:    "com.sun.xml.bind",
-						ArtifactID: "*",
-					},
-					{
-						GroupID:    "org.apache.camel",
-						ArtifactID: "camel-core",
-					},
-					{
-						GroupID:    "org.apache.camel",
-						ArtifactID: "camel-core-starter",
-					},
-					{
-						GroupID:    "org.apache.camel",
-						ArtifactID: "camel-spring-boot-starter",
-					},
-					{
-						GroupID:    "org.springframework.boot",
-						ArtifactID: "spring-boot-starter",
-					},
-				},
-			})
-		case strings.HasPrefix(d, "camel-k:"):
-			artifactID := strings.TrimPrefix(d, "camel-k:")
-
-			if !strings.HasPrefix(artifactID, "camel-") {
-				artifactID = "camel-" + artifactID
-			}
-
-			ctx.Project.AddDependencyGAV("org.apache.camel.k", artifactID, ctx.Build.RuntimeVersion)
-		case strings.HasPrefix(d, "mvn:"):
-			mid := strings.TrimPrefix(d, "mvn:")
-			gav := strings.Replace(mid, "/", ":", -1)
-
-			ctx.Project.AddEncodedDependencyGAV(gav)
-		case strings.HasPrefix(d, "runtime:"):
-			if d == "runtime:jvm" {
-				// common
-				continue
-			}
-			if d == "runtime:spring-boot" {
-				// common
-				continue
-			}
-
-			artifactID := strings.Replace(d, "runtime:", "camel-k-runtime-", 1)
-			dependency := maven.NewDependency("org.apache.camel.k", artifactID, ctx.Build.RuntimeVersion)
-
-			ctx.Project.AddDependency(dependency)
-		case strings.HasPrefix(d, "bom:"):
-			// no-op
-		default:
-			return fmt.Errorf("unknown dependency type: %s", d)
-		}
-	}
-
-	return nil
-}
diff --git a/pkg/builder/springboot/generator_test.go b/pkg/builder/springboot/generator_test.go
deleted file mode 100644
index 97935e2..0000000
--- a/pkg/builder/springboot/generator_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package springboot
-
-import (
-	"testing"
-
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-	"github.com/apache/camel-k/pkg/builder"
-	"github.com/apache/camel-k/pkg/util/defaults"
-	"github.com/apache/camel-k/pkg/util/maven"
-	"github.com/apache/camel-k/pkg/util/test"
-
-	"github.com/stretchr/testify/assert"
-)
-
-func TestMavenRepositories(t *testing.T) {
-	catalog, err := test.DefaultCatalog()
-	assert.Nil(t, err)
-
-	ctx := builder.Context{
-		Catalog: catalog,
-		Build: v1alpha1.BuildSpec{
-			RuntimeVersion: defaults.RuntimeVersion,
-			Platform: v1alpha1.IntegrationPlatformSpec{
-				Build: v1alpha1.IntegrationPlatformBuildSpec{
-					CamelVersion: catalog.Version,
-				},
-			},
-			Dependencies: []string{
-				"runtime:jvm",
-			},
-			Repositories: []string{
-				"https://repository.apache.org/content/repositories/snapshots@id=apache.snapshots@snapshots@noreleases",
-				"https://oss.sonatype.org/content/repositories/snapshots/@id=sonatype.snapshots@snapshots",
-			},
-		},
-	}
-
-	err = generateProject(&ctx)
-	assert.Nil(t, err)
-	err = builder.Steps.InjectDependencies.Execute(&ctx)
-	assert.Nil(t, err)
-
-	assert.Equal(t, 2, len(ctx.Project.Repositories))
-	assert.Equal(t, 2, len(ctx.Project.PluginRepositories))
-
-	assert.Contains(t, ctx.Project.Repositories, maven.Repository{
-		ID:        "apache.snapshots",
-		URL:       "https://repository.apache.org/content/repositories/snapshots",
-		Snapshots: maven.RepositoryPolicy{Enabled: true},
-		Releases:  maven.RepositoryPolicy{Enabled: false},
-	})
-
-	assert.Contains(t, ctx.Project.Repositories, maven.Repository{
-		ID:        "sonatype.snapshots",
-		URL:       "https://oss.sonatype.org/content/repositories/snapshots/",
-		Snapshots: maven.RepositoryPolicy{Enabled: true},
-		Releases:  maven.RepositoryPolicy{Enabled: true},
-	})
-
-	assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
-		ID:        "apache.snapshots",
-		URL:       "https://repository.apache.org/content/repositories/snapshots",
-		Snapshots: maven.RepositoryPolicy{Enabled: true},
-		Releases:  maven.RepositoryPolicy{Enabled: false},
-	})
-
-	assert.Contains(t, ctx.Project.PluginRepositories, maven.Repository{
-		ID:        "sonatype.snapshots",
-		URL:       "https://oss.sonatype.org/content/repositories/snapshots/",
-		Snapshots: maven.RepositoryPolicy{Enabled: true},
-		Releases:  maven.RepositoryPolicy{Enabled: true},
-	})
-}
diff --git a/pkg/builder/springboot/initializer.go b/pkg/builder/springboot/initializer.go
deleted file mode 100644
index aaebf67..0000000
--- a/pkg/builder/springboot/initializer.go
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package springboot
-
-import (
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-	"github.com/apache/camel-k/pkg/builder"
-)
-
-func initialize(ctx *builder.Context) error {
-	// do not take into account any image that does not have spring-boot
-	// as required dependency to avoid picking up a base image with wrong
-	// classpath or layout
-	ctx.ContextFilter = func(context *v1alpha1.IntegrationContext) bool {
-		for _, i := range context.Spec.Dependencies {
-			if i == "runtime:spring" {
-				return true
-			}
-		}
-
-		return false
-	}
-
-	return nil
-}
diff --git a/pkg/builder/springboot/springboot.go b/pkg/builder/springboot/springboot.go
deleted file mode 100644
index 2643e39..0000000
--- a/pkg/builder/springboot/springboot.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package springboot
-
-import (
-	"github.com/apache/camel-k/pkg/builder"
-)
-
-func init() {
-	builder.RegisterSteps(Steps)
-}
-
-type steps struct {
-	Initialize          builder.Step
-	ComputeDependencies builder.Step
-	GenerateProject     builder.Step
-}
-
-var Steps = steps{
-	Initialize: builder.NewStep(
-		builder.InitPhase,
-		initialize,
-	),
-	ComputeDependencies: builder.NewStep(
-		builder.ProjectBuildPhase+1,
-		computeDependencies,
-	),
-	GenerateProject: builder.NewStep(
-		builder.ProjectGenerationPhase,
-		generateProject,
-	),
-}
diff --git a/pkg/trait/springboot.go b/pkg/trait/springboot.go
deleted file mode 100644
index ae033e7..0000000
--- a/pkg/trait/springboot.go
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
-the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package trait
-
-import (
-	"sort"
-	"strings"
-
-	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
-	"github.com/apache/camel-k/pkg/builder"
-	"github.com/apache/camel-k/pkg/builder/springboot"
-	"github.com/apache/camel-k/pkg/util"
-	"github.com/apache/camel-k/pkg/util/envvar"
-)
-
-type springBootTrait struct {
-	BaseTrait `property:",squash"`
-}
-
-func newSpringBootTrait() *springBootTrait {
-	return &springBootTrait{
-		BaseTrait: newBaseTrait("springboot"),
-	}
-}
-
-func (t *springBootTrait) Configure(e *Environment) (bool, error) {
-	if t.Enabled == nil || !*t.Enabled {
-		return false, nil
-	}
-
-	if e.IntegrationContextInPhase(v1alpha1.IntegrationContextPhaseBuildSubmitted) {
-		return true, nil
-	}
-	if e.InPhase(v1alpha1.IntegrationContextPhaseReady, v1alpha1.IntegrationPhaseDeploying) {
-		return true, nil
-	}
-	if e.IntegrationInPhase("") {
-		return true, nil
-	}
-
-	return false, nil
-}
-
-func (t *springBootTrait) Apply(e *Environment) error {
-	//
-	// Integration
-	//
-	if e.IntegrationInPhase("") {
-		util.StringSliceUniqueAdd(&e.Integration.Status.Dependencies, "runtime:spring-boot")
-
-		// sort the dependencies to get always the same list if they don't change
-		sort.Strings(e.Integration.Status.Dependencies)
-	}
-
-	if e.InPhase(v1alpha1.IntegrationContextPhaseReady, v1alpha1.IntegrationPhaseDeploying) {
-		// Remove classpath
-		envvar.Remove(&e.EnvVars, "JAVA_CLASSPATH")
-
-		// Override env vars
-		envvar.SetVal(&e.EnvVars, "JAVA_MAIN_CLASS", "org.springframework.boot.loader.PropertiesLauncher")
-
-		deps := make([]string, 0, 2+len(e.IntegrationContext.Status.Artifacts))
-		deps = append(deps, "/etc/camel/resources")
-		deps = append(deps, "./resources")
-
-		for _, artifact := range e.IntegrationContext.Status.Artifacts {
-			if strings.HasPrefix(artifact.ID, "org.apache.camel.k:camel-k-runtime-spring-boot:") {
-				// do not include runner jar
-				continue
-			}
-			if strings.HasPrefix(artifact.ID, "org.apache.logging.log4j:") {
-				// do not include logging, deps are embedded in runner jar
-				continue
-			}
-
-			deps = append(deps, artifact.Target)
-		}
-
-		if e.IntegrationContext.Labels["camel.apache.org/context.type"] == v1alpha1.IntegrationContextTypeExternal {
-			//
-			// In case of an external created context. we do not have any information about
-			// the classpath so we assume the all jars in /deployments/dependencies/ have
-			// to be taken into account
-			//
-			deps = append(deps, "/deployments/dependencies/")
-		}
-
-		envvar.SetVal(&e.EnvVars, "LOADER_HOME", "/deployments")
-		envvar.SetVal(&e.EnvVars, "LOADER_PATH", strings.Join(deps, ","))
-	}
-	//
-	// Integration IntegrationContext
-	//
-	if e.IntegrationContextInPhase(v1alpha1.IntegrationContextPhaseBuildSubmitted) {
-		// add custom initialization logic
-		e.Steps = append(e.Steps, springboot.Steps.Initialize)
-		e.Steps = append(e.Steps, springboot.Steps.ComputeDependencies)
-
-		// replace project generator
-		for i := 0; i < len(e.Steps); i++ {
-			if e.Steps[i].Phase() == builder.ProjectGenerationPhase {
-				e.Steps[i] = springboot.Steps.GenerateProject
-			}
-		}
-	}
-
-	return nil
-}
diff --git a/pkg/trait/trait_catalog.go b/pkg/trait/trait_catalog.go
index 1a13115..339f7db 100644
--- a/pkg/trait/trait_catalog.go
+++ b/pkg/trait/trait_catalog.go
@@ -48,7 +48,6 @@ type Catalog struct {
 	tOwner            Trait
 	tImages           Trait
 	tBuilder          Trait
-	tSpringBoot       Trait
 	tIstio            Trait
 	tEnvironment      Trait
 	tClasspath        Trait
@@ -79,7 +78,6 @@ func NewCatalog(ctx context.Context, c client.Client) *Catalog {
 		tOwner:            newOwnerTrait(),
 		tImages:           newImagesTrait(),
 		tBuilder:          newBuilderTrait(),
-		tSpringBoot:       newSpringBootTrait(),
 		tIstio:            newIstioTrait(),
 		tEnvironment:      newEnvironmentTrait(),
 		tClasspath:        newClasspathTrait(),
@@ -118,7 +116,6 @@ func (c *Catalog) allTraits() []Trait {
 		c.tOwner,
 		c.tImages,
 		c.tBuilder,
-		c.tSpringBoot,
 		c.tIstio,
 		c.tEnvironment,
 		c.tClasspath,
@@ -141,7 +138,6 @@ func (c *Catalog) traitsFor(environment *Environment) []Trait {
 			c.tImages,
 			c.tBuilder,
 			c.tEnvironment,
-			c.tSpringBoot,
 			c.tJolokia,
 			c.tPrometheus,
 			c.tDeployer,
@@ -164,7 +160,6 @@ func (c *Catalog) traitsFor(environment *Environment) []Trait {
 			c.tImages,
 			c.tBuilder,
 			c.tEnvironment,
-			c.tSpringBoot,
 			c.tJolokia,
 			c.tPrometheus,
 			c.tDeployer,
@@ -188,7 +183,6 @@ func (c *Catalog) traitsFor(environment *Environment) []Trait {
 			c.tImages,
 			c.tBuilder,
 			c.tEnvironment,
-			c.tSpringBoot,
 			c.tDeployer,
 			c.tDeployment,
 			c.tAffinity,
diff --git a/test/builder_integration_test.go b/test/builder_integration_test.go
index e57a4de..6fddfc7 100644
--- a/test/builder_integration_test.go
+++ b/test/builder_integration_test.go
@@ -30,7 +30,6 @@ import (
 	"github.com/apache/camel-k/pkg/builder"
 	_ "github.com/apache/camel-k/pkg/builder/kaniko"
 	"github.com/apache/camel-k/pkg/builder/s2i"
-	_ "github.com/apache/camel-k/pkg/builder/springboot"
 	"github.com/apache/camel-k/pkg/util/defaults"
 	"github.com/apache/camel-k/pkg/util/test"