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 2019/11/04 16:11:02 UTC

[camel-k] 38/38: feat(quarkus): Use the Camel K runtime plugin to list runtime dependencies

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

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

commit 4f6886a7d06f6ae6ca52b24b279adb73dd7b4f9c
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Nov 4 09:38:33 2019 +0100

    feat(quarkus): Use the Camel K runtime plugin to list runtime dependencies
---
 pkg/builder/runtime/quarkus.go | 47 +++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/pkg/builder/runtime/quarkus.go b/pkg/builder/runtime/quarkus.go
index 265e0da..480fbac 100644
--- a/pkg/builder/runtime/quarkus.go
+++ b/pkg/builder/runtime/quarkus.go
@@ -1,12 +1,13 @@
 package runtime
 
 import (
-	"bufio"
-	"bytes"
 	"fmt"
+	"io/ioutil"
 	"os"
 	"path"
 
+	yaml2 "gopkg.in/yaml.v2"
+
 	"github.com/pkg/errors"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
@@ -68,11 +69,6 @@ func generateQuarkusProject(ctx *builder.Context) error {
 	p.Build.Plugins = append(p.Build.Plugins,
 		maven.Plugin{
 			GroupID:    "io.quarkus",
-			ArtifactID: "quarkus-bootstrap-maven-plugin",
-			Version:    ctx.Build.RuntimeProvider.Quarkus.QuarkusVersion,
-		},
-		maven.Plugin{
-			GroupID:    "io.quarkus",
 			ArtifactID: "quarkus-maven-plugin",
 			Version:    ctx.Build.RuntimeProvider.Quarkus.QuarkusVersion,
 			Executions: []maven.Execution{
@@ -96,36 +92,41 @@ func computeQuarkusDependencies(ctx *builder.Context) error {
 	mc.LocalRepository = ctx.Build.Platform.Build.Maven.LocalRepository
 	mc.Timeout = ctx.Build.Platform.Build.Maven.Timeout.Duration
 
-	// Build the project, as the quarkus-bootstrap plugin build-tree goal
-	// requires the artifact to be installed
-	mc.AddArgument("install")
+	// Build the project
+	mc.AddArgument("package")
 	if err := maven.Run(mc); err != nil {
 		return errors.Wrap(err, "failure while building project")
 	}
 
-	// Call the Quarkus dependencies plugin
+	// Retrieve the runtime dependencies
 	mc.AdditionalArguments = nil
-	mc.AddArguments("quarkus-bootstrap:build-tree")
-	output := new(bytes.Buffer)
-	// TODO: improve logging while capturing output
-	mc.Stdout = output
+	mc.AddArgumentf("org.apache.camel.k:camel-k-maven-plugin:%s:generate-dependency-list", ctx.Catalog.RuntimeVersion)
 	if err := maven.Run(mc); err != nil {
-		return errors.Wrap(err, "failure while determining dependencies")
+		return errors.Wrap(err, "failure while determining classpath")
+	}
+
+	dependencies := path.Join(mc.Path, "target", "dependencies.yaml")
+	content, err := ioutil.ReadFile(dependencies)
+	if err != nil {
+		return err
 	}
 
-	scanner := bufio.NewScanner(output)
-	scanner.Split(bufio.ScanLines)
-	for scanner.Scan() {
-		gav, err := maven.ParseGAV(scanner.Text())
+	cp := make(map[string][]v1alpha1.Artifact)
+	err = yaml2.Unmarshal(content, &cp)
+	if err != nil {
+		return err
+	}
+
+	for _, e := range cp["dependencies"] {
+		gav, err := maven.ParseGAV(e.ID)
 		if err != nil {
-			continue
+			return nil
 		}
 
 		fileName := gav.GroupID + "." + gav.ArtifactID + "-" + gav.Version + "." + gav.Type
 		location := path.Join(mc.Path, "target", "lib", fileName)
 		_, err = os.Stat(location)
-		// We check that the dependency actually exists in the lib directory as the
-		// quarkus-bootstrap Maven plugin reports deployment dependencies as well
+		// We check that the dependency actually exists in the lib directory
 		if os.IsNotExist(err) {
 			continue
 		}