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 05be4fd05831 CAMEL-26612: camel-jbang - camel eval --isolated and 
camel transform message do not load the plugins (#29222)
05be4fd05831 is described below

commit 05be4fd058314c6938ea06e812f3b7e302df6bd4
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 5 13:05:55 2026 +0100

    CAMEL-26612: camel-jbang - camel eval --isolated and camel transform 
message do not load the plugins (#29222)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../apache/camel/dsl/jbang/core/commands/Run.java  | 13 ++++++-
 .../core/commands/RunTransformMessageTest.java     | 40 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index b43b7981b4a9..b9cea617e915 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -686,6 +686,17 @@ public class Run extends CamelCommand {
     }
 
     public Integer runTransformMessage(String camelVersion, MavenResolverMixin 
mavenResolver) throws Exception {
+        prepareTransformMessage(camelVersion, mavenResolver);
+        return run();
+    }
+
+    /**
+     * The options of the empty Camel that boots in the background to 
transform a message or evaluate an expression
+     * (camel transform message, camel eval --isolated). It needs no plugins: 
loading them resolves every configured
+     * plugin, and when this runs in another JVM, such as a test, it caches 
their class path for the user's Camel CLI
+     * with the class path of that JVM.
+     */
+    void prepareTransformMessage(String camelVersion, MavenResolverMixin 
mavenResolver) {
         // just boot silently an empty camel in the background and exit
         this.transformMessageRun = true;
         this.background = true;
@@ -693,8 +704,8 @@ public class Run extends CamelCommand {
         this.mavenResolver = mavenResolver;
         this.empty = true;
         this.ignoreLoadingError = true;
+        this.skipPlugins = true;
         this.name = "transform";
-        return run();
     }
 
     protected Integer runScript(String file) throws Exception {
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTransformMessageTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTransformMessageTest.java
new file mode 100644
index 000000000000..7337291173b6
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunTransformMessageTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.camel.dsl.jbang.core.commands;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class RunTransformMessageTest {
+
+    @Test
+    void theEmptyCamelOfATransformLoadsNoPlugins() {
+        // camel eval --isolated and camel transform message boot an empty 
Camel. Loading the plugins there is not
+        // needed, and EvalSimpleTest, which uses the home of the developer, 
then rewrote the plugin class path cache of
+        // the developer's Camel CLI with the class path of the test JVM 
(camel test run failed after that)
+        Run run = new Run(new CamelJBangMain());
+        run.prepareTransformMessage("4.24.0", null);
+
+        assertThat(run.skipPlugins).isTrue();
+        assertThat(run.transformMessageRun).isTrue();
+        assertThat(run.empty).isTrue();
+        assertThat(run.background).isTrue();
+        assertThat(run.camelVersion).isEqualTo("4.24.0");
+    }
+
+}

Reply via email to