You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/06/17 07:56:04 UTC

[camel] branch main updated: camel-jbang - Export should include used dependencies

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 398d943ba5b camel-jbang - Export should include used dependencies
398d943ba5b is described below

commit 398d943ba5bc57a7a4ceffca069a880319a86dcd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 17 09:55:52 2022 +0200

    camel-jbang - Export should include used dependencies
---
 .../main/download/MavenDependencyDownloader.java     | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MavenDependencyDownloader.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MavenDependencyDownloader.java
index 7effa90c69c..0bbd3ab4914 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MavenDependencyDownloader.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/MavenDependencyDownloader.java
@@ -139,9 +139,9 @@ public class MavenDependencyDownloader extends ServiceSupport implements Depende
                     = (DependencyDownloaderClassLoader) camelContext.getApplicationContextClassLoader();
             for (MavenArtifact a : artifacts) {
                 File file = a.getFile();
-                // only add to classpath if not already present
+                // only add to classpath if not already present (do not trigger listener)
                 if (!alreadyOnClasspath(a.getGav().getGroupId(), a.getGav().getArtifactId(),
-                        a.getGav().getVersion())) {
+                        a.getGav().getVersion(), false)) {
                     classLoader.addFile(file);
                     LOG.trace("Added classpath: {}", a.getGav());
                 }
@@ -149,7 +149,12 @@ public class MavenDependencyDownloader extends ServiceSupport implements Depende
         }, gav);
     }
 
+
     public boolean alreadyOnClasspath(String groupId, String artifactId, String version) {
+        return alreadyOnClasspath(groupId, artifactId, version, true);
+    }
+
+    private boolean alreadyOnClasspath(String groupId, String artifactId, String version, boolean listener) {
         // if no artifact then regard this as okay
         if (artifactId == null) {
             return true;
@@ -163,10 +168,8 @@ public class MavenDependencyDownloader extends ServiceSupport implements Depende
         if (bootClasspath != null) {
             for (String s : bootClasspath) {
                 if (s.contains(target)) {
-                    // trigger listener
-                    DownloadListener listener = camelContext.getExtension(DownloadListener.class);
-                    if (listener != null) {
-                        listener.onAlreadyDownloadedDependency(groupId, artifactId, version);
+                    if (listener && downloadListener != null) {
+                        downloadListener.onDownloadDependency(groupId, artifactId, version);
                     }
                     // already on classpath
                     return true;
@@ -182,9 +185,8 @@ public class MavenDependencyDownloader extends ServiceSupport implements Depende
                     String s = u.toString();
                     if (s.contains(target)) {
                         // trigger listener
-                        DownloadListener listener = camelContext.getExtension(DownloadListener.class);
-                        if (listener != null) {
-                            listener.onAlreadyDownloadedDependency(groupId, artifactId, version);
+                        if (listener && downloadListener != null) {
+                            downloadListener.onDownloadDependency(groupId, artifactId, version);
                         }
                         // already on classpath
                         return true;