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 2020/03/24 16:42:00 UTC

[camel] 01/02: CAMEL-14776: came:run with osgi blueprint updated after osgi moved to camel-karaf repo

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

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

commit dfbb53a693a853992c83b560e513e069062c620e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Mar 24 17:38:26 2020 +0100

    CAMEL-14776: came:run with osgi blueprint updated after osgi moved to camel-karaf repo
---
 tooling/maven/camel-maven-plugin/pom.xml           |  5 -----
 .../main/java/org/apache/camel/maven/RunMojo.java  | 26 +++++++++++++++++-----
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tooling/maven/camel-maven-plugin/pom.xml b/tooling/maven/camel-maven-plugin/pom.xml
index dac5ab7..75b7758 100644
--- a/tooling/maven/camel-maven-plugin/pom.xml
+++ b/tooling/maven/camel-maven-plugin/pom.xml
@@ -86,11 +86,6 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-spring-javaconfig</artifactId>
         </dependency>
-        <!-- camel-test-blueprint has Main class for running blueprint out of container -->
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test-blueprint</artifactId>
-        </dependency>
         <!-- camel-cdi has Main class for running CDI -->
         <dependency>
             <groupId>org.apache.camel</groupId>
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
index 41fe6ab..93e364f 100644
--- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
@@ -314,7 +314,7 @@ public class RunMojo extends AbstractExecMojo {
     private Properties originalSystemProperties;
 
     private String extraPluginDependencyArtifactId;
-    
+
 
     /**
      * Execute goal.
@@ -405,9 +405,7 @@ public class RunMojo extends AbstractExecMojo {
             extraPluginDependencyArtifactId = "camel-cdi";
             getLog().info("Using " + mainClass + " to initiate a CamelContext");
         } else if (usingBlueprintMain) {
-            mainClass = "org.apache.camel.test.blueprint.Main";
-            // must include plugin dependencies for blueprint
-            extraPluginDependencyArtifactId = "camel-test-blueprint";
+            mainClass = "org.apache.camel.blueprint.Main";
             // set the configAdmin pid
             if (configAdminPid != null) {
                 args.add("-pid");
@@ -418,7 +416,7 @@ public class RunMojo extends AbstractExecMojo {
                 args.add("-pf");
                 args.add(configAdminFileName);
             }
-            getLog().info("Using org.apache.camel.test.blueprint.Main to initiate a CamelContext");
+            getLog().info("Using org.apache.camel.blueprint.Main to initiate a CamelContext");
         } else if (mainClass != null) {
             getLog().info("Using custom " + mainClass + " to initiate a CamelContext");
         } else {
@@ -446,6 +444,11 @@ public class RunMojo extends AbstractExecMojo {
 
         final ClassLoader loader = getClassLoader();
         IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(mainClass /* name */);
+
+        if (!detectBlueprintMainOnClassPath()) {
+            throw new MojoFailureException("Cannot run OSGi Blueprint Main because camel-blueprint-main JAR is not available on classpath");
+        }
+
         final Thread bootstrapThread = new Thread(threadGroup, new Runnable() {
             public void run() {
                 try {
@@ -702,6 +705,18 @@ public class RunMojo extends AbstractExecMojo {
         return false;
     }
 
+    @SuppressWarnings("unchecked")
+    private boolean detectBlueprintMainOnClassPath() {
+        List<Dependency> deps = project.getCompileDependencies();
+        for (Dependency dep : deps) {
+            if ("org.apache.camel.karaf".equals(dep.getGroupId()) && "camel-blueprint-main".equals(dep.getArtifactId())) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     /**
      * Set up a classloader for the execution of the main class.
      *
@@ -777,7 +792,6 @@ public class RunMojo extends AbstractExecMojo {
         try {
             Set<Artifact> artifacts = new HashSet<>(this.pluginDependencies);
             for (Artifact artifact : artifacts) {
-                // must
                 if (artifact.getArtifactId().equals(extraPluginDependencyArtifactId)
                         || artifact.getArtifactId().equals(extendedPluginDependencyArtifactId)) {
                     getLog().debug("Adding extra plugin dependency artifact: " + artifact.getArtifactId()