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 22bce4013209 CAMEL-28023: camel-jbang - Upgrade to aesh 3.19.3 (#31243)
22bce4013209 is described below
commit 22bce4013209c3e72fbb7a7941fd704883f63024
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Dec 2 10:41:54 2026 +0100
CAMEL-28023: camel-jbang - Upgrade to aesh 3.19.3 (#31243)
Upgrades the Camel CLI to aesh 3.19.3 ([release
notes](https://github.com/aeshell/aesh/releases/tag/v3.19.3)). JIRA:
[CAMEL-28023](https://issues.apache.org/jira/browse/CAMEL-28023)
## Changes
- `aesh-version` 3.19.2 → 3.19.3. Brings aesh-readline 3.19.2.
- **Named generated registry** (aeshell/aesh#785). The aesh processor now
generates its metadata registry with a fixed name:
`-AaeshRegistryClass=org.apache.camel.dsl.jbang.core.commands.GeneratedCommandMetadataRegistry`.
`CommandMetadataRegistry` asks it directly. This replaces the `Class.forName`
plus reflective constructor per command, and the list of command packages that
had to be kept up to date. A command that is not in the registry (a plugin
command) no longer costs a class pa [...]
- pom comment for `<proc>none</proc>` on test compilation: aesh 3.19.3 no
longer fails on private nested test classes. The test compile still runs
without the processor, because the tests' sub classes stand for plugin commands
without metadata (`GeneratedCommandMetadataTest`).
- Docs (Camel CLI getting started): the help colors, `NO_COLOR`, and the
new `AESH_HELP_COLORS` variable (aeshell/aesh#788).
## What changes for users
- `--help` shows sub-command names in bold instead of dark blue, and
required options really are bold (aeshell/aesh#788). Users can set their own
colors with `AESH_HELP_COLORS`. Checked through Camel's own ANSI path:
`FORCE_COLOR`/TTY, `AESH_HELP_COLORS` and `NO_COLOR` behave as described.
- Help text is unchanged: `CliHelpGoldenTest` and the parse goldens pass
without regeneration.
- Faster: median of 15 cold JVM runs, from `target/classes` with the
runtime classpath (269 JARs), JDK 25, `-XX:TieredStopAtLevel=1`:
The named registry itself saves only 1-2 ms here, within the noise; it is
mainly a simplification.
## Not affected
- aeshell/aesh#787 (class-registered commands run on per-execution forks):
Camel registers prebuilt containers with its own instances.
- aeshell/aesh#794 (`register()` no longer scans the class path): `useOnly`
in `CamelJBangMain` and `register` in the test plugin keep working.
- Citrus 5.2.1 (test plugin) ships metadata generated by aesh-processor
3.19.2. Its 31 generated classes were checked against the aesh 3.19.3 JAR:
every referenced method and field is there with the same signature, and the
implemented interfaces only gained constants. Citrus was asked to upgrade and
to pin its registry name in citrusframework/citrus#2183.
## Tests
All on JDK 25, offline against a scratch local repository with the changed
modules:
- camel-jbang-core: 3471 + 50 (serial-test), 0 failures, the help and parse
goldens unchanged
- camel-jbang-run 404, camel-jbang-mcp 494, plugin-kubernetes 195 (incl.
`KubernetesExportMetadataTest`), plugin-test 18, plugin-tui 2692,
plugin-validate 24, plugin-generate 44, plugin-edit 4, plugin-mcp 1,
camel-launcher 426: all green
- launcher distribution: `camel version`, `ps`, `get --help`, `test
--help`, `test run --help`, `test agent run --help` (Citrus metadata from
aesh-processor 3.19.2 on the 3.19.3 runtime), `kubernetes export --help` (own
options) and a usage error
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../ROOT/pages/camel-jbang-getting-started.adoc | 11 +++++
dsl/camel-jbang/camel-jbang-core/pom.xml | 13 ++++--
.../dsl/jbang/core/commands/CamelJBangMain.java | 18 ++------
.../jbang/core/common/CommandMetadataRegistry.java | 54 +++++-----------------
.../commands/GeneratedCommandMetadataTest.java | 2 +-
parent/pom.xml | 2 +-
6 files changed, 37 insertions(+), 63 deletions(-)
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-jbang-getting-started.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-getting-started.adoc
index 8808445d02c6..73b25e849489 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-getting-started.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-getting-started.adoc
@@ -272,6 +272,17 @@ camel run --help
camel init --help
----
+In a terminal, the help has colors: the command names are bold, the option
names yellow, and the values cyan. There
+are no colors when the output goes to a pipe or a file, or when `NO_COLOR` is
set. To change the colors, set
+`AESH_HELP_COLORS` to `key=value` entries separated by a colon. The keys are
`commands`, `options`, `parameters`
+(the positional arguments), `optionParams` (the values of the options) and
`required`. The value is a
+comma-separated list of styles, such as `bold`, `underline`, a color name
(`blue`, `bright-cyan`) or `#rrggbb`:
+
+[source,bash]
+----
+export AESH_HELP_COLORS="options=bright-blue:required=bold,red"
+----
+
For the full list of commands, see the
xref:jbang-commands/camel-jbang-commands.adoc[Command Reference].
== What's next
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml
b/dsl/camel-jbang/camel-jbang-core/pom.xml
index c077d26c09d4..6f4ad88a8a17 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -312,8 +312,9 @@
<build>
<plugins>
<!-- the aesh annotation processor generates the metadata of the
commands at compile time (see
- CommandMetadataRegistry); not for the tests: aesh would also
generate it for their sub classes of
- commands, which it cannot reach when they are private nested
classes -->
+ CommandMetadataRegistry); not for the tests: their sub
classes of commands stand for the commands of
+ plugins, which have no generated metadata
(GeneratedCommandMetadataTest), and the test compilation is
+ faster without it -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -327,6 +328,8 @@
</annotationProcessorPaths>
<compilerArgs combine.children="append">
<arg>-AaeshNativeImageDisable=true</arg>
+ <!-- a fixed name for the registry of the generated
metadata, which CamelJBangMain creates -->
+
<arg>-AaeshRegistryClass=org.apache.camel.dsl.jbang.core.commands.GeneratedCommandMetadataRegistry</arg>
</compilerArgs>
</configuration>
<executions>
@@ -338,9 +341,9 @@
</execution>
</executions>
</plugin>
- <!-- the CLI uses its own registry of the generated metadata
(CommandMetadataRegistry): the one of the
- processor must not be found, as it has the metadata of
commands that a plugin extends with options of
- its own (and it is in the package of the command the
processor happens to see first) -->
+ <!-- the CLI asks the generated registry through its own
(CommandMetadataRegistry), which leaves out the
+ commands that a plugin extends with options of its own: aesh
must not find the generated registry
+ itself, when it looks for registries on the class path -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 98fb40ff9077..d7711284cfee 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -105,21 +105,13 @@ public class CamelJBangMain implements
Command<CommandInvocation> {
private static CommandTree commandLine;
/**
- * The aesh metadata of the commands of the CLI, which the aesh annotation
processor generates: the packages of all
- * the commands of camel-jbang-core. Export is extended by
KubernetesExport, which has options of its own (and its
- * super classes have no metadata, so they are not looked up).
+ * The aesh metadata of the commands of the CLI, which the aesh annotation
processor generates, together with its
+ * registry GeneratedCommandMetadataRegistry (the aeshRegistryClass option
in the pom). Export is extended by
+ * KubernetesExport, which has options of its own (and its super classes
have no metadata, so they are not looked
+ * up).
*/
static final CommandMetadataRegistry COMMAND_METADATA = new
CommandMetadataRegistry(
- CamelJBangMain.class.getClassLoader(),
- Set.of("org.apache.camel.dsl.jbang.core.commands",
- "org.apache.camel.dsl.jbang.core.commands.action",
- "org.apache.camel.dsl.jbang.core.commands.catalog",
- "org.apache.camel.dsl.jbang.core.commands.config",
- "org.apache.camel.dsl.jbang.core.commands.infra",
- "org.apache.camel.dsl.jbang.core.commands.plugin",
- "org.apache.camel.dsl.jbang.core.commands.process",
- "org.apache.camel.dsl.jbang.core.commands.update",
- "org.apache.camel.dsl.jbang.core.commands.version"),
+ new GeneratedCommandMetadataRegistry(),
Set.of("org.apache.camel.dsl.jbang.core.commands.Export",
"org.apache.camel.dsl.jbang.core.commands.ExportBaseCommand",
"org.apache.camel.dsl.jbang.core.commands.CamelCommand"));
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandMetadataRegistry.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandMetadataRegistry.java
index 1eec53cc65b2..c34758115ab6 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandMetadataRegistry.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CommandMetadataRegistry.java
@@ -22,17 +22,12 @@ import org.aesh.command.metadata.CommandMetadataProvider;
import org.aesh.command.metadata.MetadataRegistry;
/**
- * The aesh metadata of the commands in the given packages, which the aesh
annotation processor generates at compile
- * time: aesh then does not read the annotations of a command at run time,
which creates a proxy class for each kind of
- * annotation.
+ * The aesh metadata of the commands of the CLI, which the aesh annotation
processor generates at compile time: aesh
+ * then does not read the annotations of a command at run time, which creates
a proxy class for each kind of annotation.
* <p>
- * The metadata of a command is the class {@code <command class>_AeshMetadata}
in the package of the command (a nested
- * class {@code Outer$Inner} has {@code Outer_Inner_AeshMetadata}). The
registry that the processor generates is not
- * used, as it is in the package of the command that the processor happens to
see first.
- * <p>
- * Only the commands of the given packages are looked up: all the commands of
the CLI and its plugins are in packages of
- * {@code org.apache.camel.dsl.jbang.core.commands}, and a class that is not
there costs a search of the whole class
- * path.
+ * The processor also generates a registry of that metadata, with a fixed name
(the {@code aeshRegistryClass} option in
+ * the pom of camel-jbang-core), which this registry asks: a command that is
not in it (such as the command of a plugin)
+ * costs no search of the class path.
* <p>
* aesh looks up the metadata of a command class, and then of its super
classes, so a command without metadata of its
* own gets the metadata of the command it extends, which misses its own
options. A command that a plugin extends with
@@ -45,20 +40,15 @@ import org.aesh.command.metadata.MetadataRegistry;
// not a record (see above): do not convert it to one
public final class CommandMetadataRegistry implements MetadataRegistry {
- private static final String SUFFIX = "_AeshMetadata";
-
- private final ClassLoader classLoader;
- private final Set<String> packages;
+ private final MetadataRegistry generated;
private final Set<String> excluded;
/**
- * @param classLoader the class loader of the commands
- * @param packages the packages of the commands
- * @param excluded the classes to read the annotations of at run time
(and their super classes without metadata)
+ * @param generated the registry that the aesh annotation processor
generates
+ * @param excluded the classes to read the annotations of at run time
(and their super classes without metadata)
*/
- public CommandMetadataRegistry(ClassLoader classLoader, Set<String>
packages, Set<String> excluded) {
- this.classLoader = classLoader;
- this.packages = packages;
+ public CommandMetadataRegistry(MetadataRegistry generated, Set<String>
excluded) {
+ this.generated = generated;
this.excluded = excluded;
}
@@ -68,28 +58,6 @@ public final class CommandMetadataRegistry implements
MetadataRegistry {
@Override
public CommandMetadataProvider<?> get(String commandClassName) {
- int dot = commandClassName.lastIndexOf('.');
- if (dot < 0 || !packages.contains(commandClassName.substring(0, dot))
|| excluded.contains(commandClassName)) {
- return null;
- }
- String simpleName = commandClassName.substring(dot + 1);
- int nested = simpleName.indexOf('$');
- if (nested >= 0 && nested + 1 < simpleName.length() &&
Character.isDigit(simpleName.charAt(nested + 1))) {
- // an anonymous or local class has no metadata of its own (aesh
uses the one of its super class)
- return null;
- }
- // String.concat, not +: the first string concatenation with + starts
the method handles of the JDK, which
- // costs more than the metadata saves on a short command (measured on
JDK 25: camel ps exited after 47 ms of
- // JVM time with +, 45 ms with String.concat, and 40 ms when the
record and the verification of CamelJBangMain
- // did not start them either)
- String name = commandClassName.substring(0, dot +
1).concat(simpleName.replace('$', '_')).concat(SUFFIX);
- try {
- Class<?> type = Class.forName(name, true, classLoader);
- return (CommandMetadataProvider<?>)
type.getDeclaredConstructor().newInstance();
- } catch (ClassNotFoundException e) {
- return null;
- } catch (ReflectiveOperationException e) {
- throw new IllegalStateException("Cannot create the aesh metadata "
+ name, e);
- }
+ return excluded.contains(commandClassName) ? null :
generated.get(commandClassName);
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/GeneratedCommandMetadataTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/GeneratedCommandMetadataTest.java
index 850b3312ae44..60a5e67b70d8 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/GeneratedCommandMetadataTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/GeneratedCommandMetadataTest.java
@@ -58,7 +58,7 @@ class GeneratedCommandMetadataTest {
}
CommandMetadataProvider<?> provider =
CamelJBangMain.COMMAND_METADATA.get(name);
if (provider == null || provider.commandType() !=
command.getClass()) {
- // a command in a package that is not in COMMAND_METADATA, or
that the processor did not see
+ // a command that the processor did not see
missing.add(name);
}
}
diff --git a/parent/pom.xml b/parent/pom.xml
index 3d071ca49ca8..e3dde9835e8d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -61,7 +61,7 @@
<activemq-version>5.19.12</activemq-version>
<activemq6-version>6.4.0</activemq6-version>
<activemq-artemis-version>2.57.0</activemq-artemis-version>
- <aesh-version>3.19.2</aesh-version>
+ <aesh-version>3.19.3</aesh-version>
<agroal-version>3.3</agroal-version>
<allegro-converter-version>0.3.0</allegro-converter-version>
<alibabacloud-oss-version>0.6.1</alibabacloud-oss-version>