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 2021/05/31 17:20:49 UTC
[camel] branch main updated: CAMEL-16673: camel-maven-plugin - Move
OSGi to its own camel-karaf-maven-plugin
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 2c46902 CAMEL-16673: camel-maven-plugin - Move OSGi to its own camel-karaf-maven-plugin
2c46902 is described below
commit 2c469022a14b4cc0120b6c1403d3396432b7195f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon May 31 19:17:33 2021 +0200
CAMEL-16673: camel-maven-plugin - Move OSGi to its own camel-karaf-maven-plugin
---
.../ROOT/pages/camel-3x-upgrade-guide-3_11.adoc | 35 +++++++++++
.../src/main/docs/camel-maven-plugin.adoc | 50 +--------------
.../main/java/org/apache/camel/maven/RunMojo.java | 73 +---------------------
3 files changed, 38 insertions(+), 120 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_11.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_11.adoc
index 8e8d5d5..23f391f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_11.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_11.adoc
@@ -10,3 +10,38 @@ from both 3.0 to 3.1 and 3.1 to 3.2.
The camel-saxon component no longer depends on camel-xslt-saxon.
Any applications in needs of XSLT transformation with saxon should now declare an explicit dependency upon camel-xslt-saxon.
+
+=== camel-maven-plugin with OSGi blueprint
+
+The `run` goal of the `camel-maven-plugin` has moved its OSGi Blueprint support out to its own `camel-karaf-maven-plugin`.
+
+This means if you use Camel on OSGi Blueprint then you need to migrate from:
+[source,xml]
+----
+<plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>3.11.0</version>
+</plugin>
+----
+
+to
+
+[source,xml]
+----
+<plugin>
+ <groupId>org.apache.camel.karaf</groupId>
+ <artifactId>camel-karaf-maven-plugin</artifactId>
+ <version>3.11.0</version>
+</plugin>
+----
+
+In the `pom.xml` file.
+
+Also remember to execute the `run` goal, you should use `camel-karaf:run` instead of `camel:run` as shown:
+
+[source,bash]
+----
+mvn camel-karaf:run
+----
+
diff --git a/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc b/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
index 227faa0..d7e134d 100644
--- a/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
+++ b/tooling/maven/camel-maven-plugin/src/main/docs/camel-maven-plugin.adoc
@@ -38,55 +38,7 @@ The maven plugin *run* goal supports the following options which can be configur
=== Running OSGi Blueprint
-The `camel:run` plugin also supports running a Blueprint application, and by default it scans for OSGi blueprint files in
-`OSGI-INF/blueprint/*.xml`
-
-You would need to configure the camel:run plugin to use blueprint, by setting useBlueprint to true as shown below
-
-[source,xml]
-----
-<plugin>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-maven-plugin</artifactId>
- <configuration>
- <useBlueprint>true</useBlueprint>
- </configuration>
-</plugin>
-----
-
-This allows you to boot up any Blueprint services you wish - whether they are Camel-related, or any other Blueprint.
-
-The `camel:run` goal is able to auto detect if camel-blueprint is on the classpath or there is blueprint XML files
-in the project, and therefore you no longer have to configure the useBlueprint option.
-
-=== Using limited Blueprint container
-
-We use the Felix Connector project as the blueprint container. This project is not a full fledged blueprint container.
-For that you can use Apache Karaf or Apache ServiceMix.
-You can use the applicationContextUri configuration to specify an explicit blueprint XML file, such as:
-
-[source,xml]
-----
-<plugin>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-maven-plugin</artifactId>
- <configuration>
- <useBlueprint>true</useBlueprint>
- <applicationContextUri>myBlueprint.xml</applicationContextUri>
- <!-- ConfigAdmin options which have been added since Camel 2.12.0 -->
- <configAdminPid>test</configAdminPid>
- <configAdminFileName>/user/test/etc/test.cfg</configAdminFileName>
- </configuration>
-</plugin>
-----
-
-The `applicationContextUri` will currently load the file from the classpath, so in the example above the
-`myBlueprint.xml` file must be in the root of the classpath.
-
-The `configAdminPid` is the pid name which will be used as the pid name for configuration admin service when
-loading the persistence properties file.
-
-The `configAdminFileName` is the file name which will be used to load the configuration admin service properties file.
+Use the `camel-karaf-maven-plugin` which is intended for Apache Camel on Karaf/OSGi.
=== Running CDI
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 7eca7c4..5e62435 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
@@ -63,9 +63,8 @@ import org.codehaus.mojo.exec.ExecutableDependency;
import org.codehaus.mojo.exec.Property;
/**
- * Runs a CamelContext using any Spring or Blueprint XML configuration files found in
- * <code>META-INF/spring/*.xml</code>, and <code>OSGI-INF/blueprint/*.xml</code>, and <code>camel-*.xml</code> and
- * starting up the context.
+ * Runs a CamelContext using any Spring configuration files found in <code>META-INF/spring/*.xml</code>, and
+ * <code>camel-*.xml</code> and starting up the context.
*/
@Mojo(name = "run", defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
@@ -114,12 +113,6 @@ public class RunMojo extends AbstractExecMojo {
protected boolean logClasspath;
/**
- * Whether to use Blueprint when running, instead of Spring
- */
- @Parameter(property = "camel.useBlueprint")
- protected Boolean useBlueprint;
-
- /**
* Whether to use CDI when running, instead of Spring
*/
@Parameter(property = "camel.useCDI")
@@ -325,14 +318,6 @@ public class RunMojo extends AbstractExecMojo {
// auto detect if we have cdi
useCdiMain = detectCDIOnClassPath();
}
- boolean usingBlueprintMain;
- if (useBlueprint != null) {
- // use configured value
- usingBlueprintMain = useBlueprint;
- } else {
- // auto detect if we have blueprint
- usingBlueprintMain = detectBlueprintOnClassPathOrBlueprintXMLFiles();
- }
boolean usingKameletMain;
if (useKamelet != null) {
// use configured value
@@ -395,20 +380,6 @@ public class RunMojo extends AbstractExecMojo {
// must include plugin dependencies for cdi
extraPluginDependencyArtifactId = "camel-cdi";
getLog().info("Using " + mainClass + " to initiate a CamelContext");
- } else if (usingBlueprintMain) {
- mainClass = "org.apache.camel.blueprint.Main";
- // set the configAdmin pid
- if (configAdminPid != null) {
- args.add("-pid");
- args.add(configAdminPid);
- }
- // set the configAdmin pFile
- if (configAdminFileName != null) {
- args.add("-pf");
- args.add(configAdminFileName);
- }
- extraPluginDependencyArtifactId = "camel-blueprint-main";
- getLog().info("Using org.apache.camel.blueprint.Main to initiate a CamelContext");
} else if (usingKameletMain) {
mainClass = "org.apache.camel.main.KameletMain";
// must include plugin dependencies for kamelet
@@ -442,10 +413,6 @@ public class RunMojo extends AbstractExecMojo {
final ClassLoader loader = getClassLoader();
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(mainClass /* name */);
- if (usingBlueprintMain && !detectBlueprintMainOnClassPath()) {
- throw new MojoFailureException(
- "Cannot run OSGi Blueprint Main because camel-blueprint-main JAR is not available on classpath");
- }
if (usingKameletMain && !detectKameletOnClassPath()) {
throw new MojoFailureException(
"Cannot run Kamelet Main because camel-kamelet-main JAR is not available on classpath");
@@ -687,30 +654,6 @@ public class RunMojo extends AbstractExecMojo {
}
@SuppressWarnings("unchecked")
- private boolean detectBlueprintOnClassPathOrBlueprintXMLFiles() {
- List<Dependency> deps = project.getCompileDependencies();
- for (Dependency dep : deps) {
- if ("org.apache.camel".equals(dep.getGroupId()) && "camel-blueprint".equals(dep.getArtifactId())) {
- getLog().info("camel-blueprint detected on classpath");
- return true;
- }
- }
-
- // maybe there is blueprint XML files
- List<Resource> resources = project.getResources();
- for (Resource res : resources) {
- File dir = new File(res.getDirectory());
- File xml = new File(dir, "OSGI-INF/blueprint");
- if (xml.exists() && xml.isDirectory()) {
- getLog().info("OSGi Blueprint XML files detected in directory " + xml);
- return true;
- }
- }
-
- return false;
- }
-
- @SuppressWarnings("unchecked")
private boolean detectKameletOnClassPath() {
List<Dependency> deps = project.getCompileDependencies();
for (Dependency dep : deps) {
@@ -734,18 +677,6 @@ 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.
*