From 5668164beadbfa60ed2c17f6e294282b6bdcda33 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Mon, 16 Nov 2026 09:45:27 +0100 Subject: [PATCH] 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 Signed-off-by: Claus Ibsen --- .../pages/camel-4x-upgrade-guide-4_24.adoc | 8 ++++++++ .../ROOT/pages/camel-jbang-projects.adoc | 4 +++- dsl/camel-jbang/camel-launcher/pom.xml | 19 ++++++------------- .../dsl/jbang/launcher/CamelLauncherMain.java | 3 +-- .../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 199ccdb66cf43..3b64c2e91c4b1 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/-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 b4726c4594797..eb89693b176d4 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 73da9f18d023e..d2068e1b26262 100644 --- a/dsl/camel-jbang/camel-launcher/pom.xml +++ b/dsl/camel-jbang/camel-launcher/pom.xml @@ -67,13 +67,10 @@ org.commonmark @@ -98,12 +95,8 @@ - - - org.apache.camel - camel-jbang-plugin-generate - ${project.version} - + org.apache.camel camel-jbang-plugin-test 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 a9a125e046edd..59e52e516336b 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.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 factory, Set commands) { } + // not the generate plugin, which camel generate installs on first use, as it is a fifth of the download private static final List 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 b071f45afc4ed..85aeec6c39651 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.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 void quit(int exitCode) { @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 void aCommandOfAnEmbeddedPluginCreatesOnlyThatPlugin() { @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 commandsOf(String... args) {