Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9295,6 +9295,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
19 changes: 6 additions & 13 deletions dsl/camel-jbang/camel-launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -124,12 +121,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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,12 +45,12 @@ public class CamelLauncherMain extends CamelJBangMain {
private record EmbeddedPlugin(Supplier<Plugin> factory, Set<String> commands) {
}

// Lambdas, not constructor references (GeneratePlugin::new): a constructor reference loads its class when this list
// is created, so every command would load all the plugins (and the test plugin loads Citrus and picocli). Their
// Lambdas, not constructor references (KubernetesPlugin::new): a constructor reference loads its class when this
// list is created, so every command would load all the plugins (and the test plugin loads Citrus and picocli). Their
// JARs are far down the class path of the distribution, and loading a class from there opens every JAR before it.
// Not the generate plugin, which camel generate installs on first use, as it is a fifth of the download.
@SuppressWarnings("java:S1612")
private static final List<EmbeddedPlugin> PLUGINS = List.of(
new EmbeddedPlugin(() -> new GeneratePlugin(), Set.of("generate")),
new EmbeddedPlugin(() -> new KubernetesPlugin(), 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(() -> new McpPlugin(), Set.of("mcp")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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"));
Expand All @@ -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<String> commandsOf(String... args) {
Expand Down
Loading