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

davsclaus pushed a commit to branch CAMEL-27005-launcher-generate-on-first-use
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5668164beadbfa60ed2c17f6e294282b6bdcda33
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 16 09:45:27 2026 +0100

    CAMEL-27005: camel-launcher - the generate plugin installs on first use 
instead of being bundled
    
    The generate plugin and the OpenAPI generator it uses are 58 jars and a
    fifth of the Camel CLI download. camel generate installs the plugin on
    first use, as for camel edit.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc       |  8 ++++++++
 .../modules/ROOT/pages/camel-jbang-projects.adoc      |  4 +++-
 dsl/camel-jbang/camel-launcher/pom.xml                | 19 ++++++-------------
 .../camel/dsl/jbang/launcher/CamelLauncherMain.java   |  3 +--
 .../camel/dsl/jbang/launcher/CamelLauncherTest.java   | 16 ++++++++++++++--
 5 files changed, 32 insertions(+), 18 deletions(-)

diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 199ccdb66cf4..3b64c2e91c4b 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -9167,6 +9167,14 @@ could not start, such as with Docker down, was gone 
without a word. Now:
 The output of the service goes to `~/.camel/<pid>-run.log`, instead of a pipe 
that nobody read. `camel infra stop`
 removes it.
 
+=== camel-launcher - the generate plugin installs on first use
+
+The Camel CLI launcher, as installed by the install script or a package 
manager such as Homebrew, no longer has the
+generate plugin in it: the plugin and the OpenAPI generator it uses are about 
24 MB, a fifth of the download. The first
+`camel generate` downloads the plugin from Maven Central into the local Maven 
repository, and adds it to the plugin
+configuration, as for `camel edit`. To have it on a machine that is offline 
later, run `camel generate --help` once
+while it is online.
+
 === camel-jbang - camel run loads one version of each library
 
 `camel run` downloads the JARs of each component when it is first used. It now 
keeps one version of each library: when
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
index b4726c459479..eb89693b176d 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
@@ -267,7 +267,9 @@ The plugins of the Apache Camel project:
 | edit | `camel edit`: edit a Camel file in the terminal with suggestions and 
diagnostics
 |===
 
-Plugins bundled with the CLI, such as `tui`, are installed on first use.
+The plugins of the Apache Camel project are installed on first use: the first 
`camel tui` installs the tui plugin.
+The Camel CLI launcher, as installed by the install script or a package 
manager such as Homebrew, has kubernetes, test,
+validate, tui and mcp in it, and downloads generate and edit from Maven 
Central the first time they are used.
 
 Add, list installed, and remove plugins:
 
diff --git a/dsl/camel-jbang/camel-launcher/pom.xml 
b/dsl/camel-jbang/camel-launcher/pom.xml
index 73da9f18d023..d2068e1b2626 100644
--- a/dsl/camel-jbang/camel-launcher/pom.xml
+++ b/dsl/camel-jbang/camel-launcher/pom.xml
@@ -67,13 +67,10 @@
     <dependencyManagement>
         <dependencies>
             <!--
-                This launcher bundles both camel-jbang-plugin-generate and 
camel-jbang-plugin-tui on a
-                single flat classpath. The generate plugin drags in commonmark 
0.21.0 (via openapi-generator),
-                while the tui plugin (via tamboui-markdown) needs commonmark 
0.28.0 and its renderer.markdown
-                classes that do not exist in 0.21.0. Without this pin Maven 
mediation keeps the older 0.21.0
-                core next to the 0.28.0 extensions, which makes the TUI 
Markdown help throw NoClassDefFoundError.
-                Pin the core to 0.28.0 so it matches the commonmark-ext-* 
modules; openapi-generator only uses
-                the stable Parser/HtmlRenderer APIs, which are unchanged in 
0.28.0.
+                The tui plugin (via tamboui-markdown) needs a commonmark core 
that is not older than its
+                commonmark-ext-* modules. The generate plugin, which installs 
on first use, brings commonmark 0.21.0,
+                but its class loader asks the launcher first, so it uses this 
core too; openapi-generator only uses
+                the stable Parser/HtmlRenderer APIs.
             -->
             <dependency>
                 <groupId>org.commonmark</groupId>
@@ -98,12 +95,8 @@
         </dependency>
 
         <!-- Pre-installed plugins -->
-        <!-- the edit plugin is not pre-installed -->
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-jbang-plugin-generate</artifactId>
-            <version>${project.version}</version>
-        </dependency>
+        <!-- the edit and generate plugins are not pre-installed: they install 
on first use
+             (generate and its OpenAPI generator are about 24 MB, a fifth of 
the download) -->
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-jbang-plugin-test</artifactId>
diff --git 
a/dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherMain.java
 
b/dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherMain.java
index a9a125e046ed..59e52e516336 100644
--- 
a/dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherMain.java
+++ 
b/dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherMain.java
@@ -25,7 +25,6 @@ import java.util.Set;
 import java.util.function.Supplier;
 
 import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
-import org.apache.camel.dsl.jbang.core.commands.generate.GeneratePlugin;
 import org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesPlugin;
 import org.apache.camel.dsl.jbang.core.commands.mcp.McpPlugin;
 import org.apache.camel.dsl.jbang.core.commands.test.TestPlugin;
@@ -46,8 +45,8 @@ public class CamelLauncherMain extends CamelJBangMain {
     private record EmbeddedPlugin(Supplier<Plugin> factory, Set<String> 
commands) {
     }
 
+    // not the generate plugin, which camel generate installs on first use, as 
it is a fifth of the download
     private static final List<EmbeddedPlugin> PLUGINS = List.of(
-            new EmbeddedPlugin(GeneratePlugin::new, Set.of("generate")),
             new EmbeddedPlugin(KubernetesPlugin::new, Set.of("kubernetes", 
"k8s")),
             // its jar was in the launcher, but camel mcp installed the plugin 
on first use, in the plugin configuration
             new EmbeddedPlugin(McpPlugin::new, Set.of("mcp")),
diff --git 
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherTest.java
 
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherTest.java
index b071f45afc4e..85aeec6c3965 100644
--- 
a/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherTest.java
+++ 
b/dsl/camel-jbang/camel-launcher/src/test/java/org/apache/camel/dsl/jbang/launcher/CamelLauncherTest.java
@@ -25,13 +25,16 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.camel.dsl.jbang.core.common.CommandTree;
+import org.apache.camel.dsl.jbang.core.common.PluginHelper;
 import org.apache.camel.dsl.jbang.run.common.Printer;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
@@ -98,7 +101,6 @@ public class CamelLauncherTest {
     @Test
     public void aCommandOfAnEmbeddedPluginCreatesOnlyThatPlugin() {
         // creating all the commands of the CLI and the plugins costs more 
than half a second
-        assertEquals(Set.of("generate"), commandsOf("generate"));
         assertEquals(Set.of("kubernetes", "k8s"), commandsOf("k8s", "--help"));
         // embedded like the others, so camel mcp does not install it in the 
plugin configuration on first use
         assertEquals(Set.of("mcp"), commandsOf("mcp", "--help"));
@@ -108,7 +110,17 @@ public class CamelLauncherTest {
     @Test
     public void theHelpCreatesTheCommandsOfAllEmbeddedPlugins() {
         assertTrue(commandsOf("--help")
-                .containsAll(Set.of("version", "generate", "kubernetes", 
"mcp", "self-update", "tui", "validate", "test")));
+                .containsAll(Set.of("version", "kubernetes", "mcp", 
"self-update", "tui", "validate", "test")));
+    }
+
+    @Test
+    public void theGeneratePluginIsNotEmbedded() {
+        // camel generate installs it on first use: it and the OpenAPI 
generator are a fifth of the download (CAMEL-27005)
+        assertFalse(commandsOf("--help").contains("generate"));
+        assertTrue(PluginHelper.isPluginCommand("generate"), "camel generate 
installs the plugin on first use");
+        assertThrows(ClassNotFoundException.class,
+                () -> 
Class.forName("org.apache.camel.dsl.jbang.core.commands.generate.GeneratePlugin"));
+        assertThrows(ClassNotFoundException.class, () -> 
Class.forName("org.openapitools.codegen.DefaultGenerator"));
     }
 
     private static Set<String> commandsOf(String... args) {

Reply via email to