Skip to content

CAMEL-27232: camel-jbang - generated aesh metadata for the CLI commands - #30386

Merged
davsclaus merged 9 commits into
mainfrom
CAMEL-27232-aesh-processor
Nov 19, 2026
Merged

davsclaus merged 9 commits into
mainfrom
CAMEL-27232-aesh-processor

Conversation

@davsclaus

@davsclaus davsclaus commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

The Camel CLI now generates the aesh metadata of its commands at compile time, with the aesh annotation processor. aesh then no longer reads the annotations of a command at run time, which makes the JDK create a proxy class for each kind of annotation.

JIRA: CAMEL-27232

Stacked on #30374 (CAMEL-27230: Upgrade to aesh 3.19.2 and skip its class path scan at start-up), which it builds on (MetadataProviderRegistry.useOnly). Retarget to main once #30374 is merged. Until then the PR build does not run (stacked PR); the results below are from local runs.

Commits

  1. The CLI commands have a no-arg constructor (the processor requires one). The constructors that took the CamelJBangMain are removed: CamelJBangMain#command(T) sets the main on a new command (main.command(new Run())), and CamelCommand#getMain() fails with a clear message when the main was not set. 195 constructors removed, about 250 call sites in main code and 850 in tests changed; all camel-jbang modules and plugins. This commit does not change behaviour.
  2. Generated metadata for the commands of camel-jbang-core.
    • aesh-processor in the compiler of camel-jbang-core. It is not used for test compilation: @CommandDefinition is @Inherited, so it would also generate metadata for private nested test subclasses, which the generated code cannot reach (aesh-processor: commands without a no-arg constructor, mixin fields it cannot reach, inaccessible subclasses aeshell/aesh#785, point 3).
    • CommandMetadataRegistry finds the metadata of a command by its class name (<command>_AeshMetadata) in the packages of the commands. The registry of the processor is not used: it is in the package of the command the processor happens to see first, which can differ between machines. Its META-INF files are removed from the build output so aesh never discovers it.
    • Export is read at run time. aesh looks up the metadata of a class and then of its super classes, so KubernetesExport (which extends Export with 18 options of its own) would get the metadata of Export and lose those options. Generating it for the kubernetes plugin would need the 49 inherited option fields of ExportBaseCommand to be public. CommandTree now fails with a clear message when a command would get the metadata of a super class while it has options of its own, so a plugin command (such as one of camel-kit) cannot lose its options silently.
    • CommandTree takes the name and aliases of a command from the metadata (reading @CommandDefinition creates the annotation proxy as well).
    • The fields the generated code sets: 23 private option fields are now package-private (no reflection), and the option fields of 4 mixins used from other packages are public (aesh-processor: commands without a no-arg constructor, mixin fields it cannot reach, inaccessible subclasses aeshell/aesh#785, point 2).
  3. No method handles at start-up. Three things in the first version loaded more than the metadata saves: string concatenation with + and the equals of a record (both start the method handles of the JDK, about 200 classes), and command(new X()) in the command line of CamelJBangMain, for which the JVM loads every command class to verify it. Now camel ps loads 1,283 classes (CAMEL-27230: Upgrade to aesh 3.19.2 and skip its class path scan at start-up #30374: 1,415).
  4. Review: a note at the class declaration that it must not become a record, the measured cost in the String.concat comment, and IllegalStateException named in the upgrade guide.

Numbers

Launcher distribution, median of 15 runs after 3 warm-ups, the three builds interleaved per round, Apple M4 Pro, Java 25, CDS on (load average about 5):

Command main #30374 this PR
camel version 131 ms 96 ms 78 ms
camel ps 144 ms 103 ms 90 ms
camel get route 151 ms 124 ms 108 ms
camel catalog component 184 ms 157 ms 143 ms
camel init --help 139 ms 102 ms 91 ms
camel get --help 162 ms 125 ms 97 ms
camel run --help 201 ms 199 ms 180 ms
camel --help 251 ms 245 ms 218 ms

Testing

  • All camel-jbang modules and plugins: mvn test (camel-jbang-core 3400 tests, kubernetes 2618, launcher 420, TUI, validate, MCP, ...), 0 failures. RouteDiagramToolsTest.callsAtTheSameTime (MCP) was a flake once (JMX name of two Camel contexts started at the same time) and passed on retry and in 5 reruns.
  • The help and parse golden files of camel-jbang-core are unchanged, so the generated metadata gives the same help and the same parse results as the annotations.
  • New GeneratedCommandMetadataTest: every command of the CLI (more than 150) has generated metadata of its own; a command without the main fails clearly; a sub class with options of its own and no metadata fails.
  • New KubernetesExportMetadataTest: kubernetes export has its own options and those of Export. Without Export excluded, it fails with the message of CommandTree.
  • Smoke test of the built launcher: version, ps, get --help, kubernetes export --help (--image-registry and --runtime), test init with and without --force, self-update --help, catalog component.

The upgrade guide 4.24 (aesh section, for plugin authors) has the no-arg constructor and main.command(new MyCommand()).

Claude Code on behalf of Claus Ibsen

🤖 Generated with Claude Code

davsclaus and others added 5 commits November 19, 2026 08:15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…a registries

The CLI commands have no generated aesh metadata, so the CLI tells aesh 3.19.2 to use only its internal
registry (MetadataProviderRegistry.useOnly) instead of looking through every JAR on the class path. The
test plugin registers the generated aesh metadata of the Citrus commands it extends. Takes 30-40 ms off
camel version, ps, get route and catalog component.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…, and get the main set after creation

The aesh annotation processor generates the metadata of a command only when it has a no-arg constructor. The
constructors that took the CamelJBangMain are removed: CamelJBangMain#command(T) sets the main on a new command
(main.command(new Run())), and CamelCommand#getMain() fails clearly when it was not set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…enerated at compile time

The aesh annotation processor generates the metadata of the commands of camel-jbang-core, so aesh no longer reads
their annotations at run time (which creates a proxy class for each kind of annotation). CommandMetadataRegistry finds
the metadata of a command by its class name in the packages of the commands; the registry of the processor is removed
from the jar, as it is in a package that depends on the order the processor sees the commands. CommandTree takes the
name and aliases of a command from the metadata.

aesh looks up the metadata of a command and then of its super classes, so Export (which KubernetesExport extends with
options of its own) is read at run time, and CommandTree fails when a command would get the metadata of a super class
while it has options of its own.

The option fields that the generated code sets are no longer private, and the fields of mixins used from other
packages are public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
…method handles of the JDK

Three things on the path of every command made the JVM load more than the metadata saves: the string concatenation
with + and the equals of a record (both start the method handles of the JDK, about 200 classes), and
command(new X()) in the command line of CamelJBangMain, for which the JVM loads every command class to verify
CamelJBangMain. camel ps loads 1,283 classes again, as the prototype did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus davsclaus added this to the 4.24.0 milestone Nov 19, 2026
@davsclaus davsclaus added dsl enhancement New feature or request labels Nov 19, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design is sound: separating command construction (no-arg) from main-binding (setCamelMain()) enables compile-time metadata generation while keeping the runtime contract enforced via the getMain() guard. The cmd(Object) / command(T) split cleanly separates the deferred-loading internal API from the typed plugin API.

Three low-severity comments below — no blockers.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a clean implementation of compile-time aesh metadata generation for camel-jbang commands.

The key design decisions are well-reasoned and documented:

  • cmd(Object) / command(T) split — Object parameter type intentionally prevents the JVM from verifying that every command class is a subtype of CamelCommand at class-loading time, deferring per-command class load until the command is actually invoked. The Javadoc makes the rationale explicit.
  • CommandMetadataRegistry as a plain class (not a record) — the commit message explains that record#equals triggers JDK method handles (~200 classes), costing more than the metadata saves on short commands (camel ps).
  • String.concat instead of + — same rationale (method handle avoidance). Unusual but correctly justified.
  • checkMetadataOf() guard — fires at command-tree construction time (startup) and catches the case where a plugin extends a CLI command that has generated metadata, but the plugin has options of its own that the inherited metadata doesn't cover. The KubernetesExportMetadataTest specifically validates this for KubernetesExport extends Export.
  • excluded set — correctly scoped to Export, ExportBaseCommand, and CamelCommand (the CLI's extension points for plugins). The registry returns null for these, forcing aesh to fall back to runtime annotation reflection.
  • pom.xml pattern — aesh-processor as annotationProcessorPath for main compile, <proc>none</proc> for test compile (tests have private nested subclasses of commands that the processor can't reach), maven-antrun-plugin at generate-test-sources to delete the processor's registry (which is not used — the CLI uses CommandMetadataRegistry instead).

Test coverage is solid:

  • GeneratedCommandMetadataTest.everyCommandHasGeneratedMetadataOfItsOwn loads the full command tree (150+ commands) and checks each one has its own generated metadata — this is a high-value regression guard.
  • aSubClassWithOptionsOfItsOwnAndNoMetadataFails validates the checkMetadataOf() guard directly.
  • aCommandIsCreatedWithoutTheMainAndGetsItAfterwards validates the IllegalStateException path in getMain().
  • KubernetesExportMetadataTest validates that KubernetesExport sees both its own options and Export's options (the excluded-set mechanism is exercised end-to-end).

Upgrade guide correctly instructs plugin authors on the no-arg constructor requirement and the main.command(new MyCommand()) pattern.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@github-actions github-actions Bot added the docs label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

…IllegalStateException in the upgrade guide

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three comments from the previous review are addressed in the latest commit. ✅

  • CommandMetadataRegistry: the class-level guard comment // not a record (see above): do not convert it to one is in place — future readers get the why without digging into the Javadoc.
  • String.concat rationale: the comment now includes the measured timing (45 ms with String.concat vs 47 ms with +), giving future readers a concrete data point to revisit if the JDK changes the tradeoff.
  • Upgrade guide: getMain() is described as throwing IllegalStateException, making the error searchable in stack traces.

No new issues in this commit. Good to merge.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review: CI failure — missed constructor migration in ExportDependencyTest

The latest commit merged main into the branch. CI is now failing on posix-validator (ubuntu-latest):

[ERROR] ExportDependencyTest.java:[596,26] constructor Export in class Export cannot be applied to given types;
  required: no arguments
  found: org.apache.camel.dsl.jbang.core.commands.CamelJBangMain
  reason: actual and formal argument lists differ in length

Root cause: The PR migrated new Export(new CamelJBangMain()) → new CamelJBangMain().command(new Export()) at lines 541 and 565 of ExportDependencyTest.java, but missed the third occurrence around line 596. The Export constructor no longer accepts a CamelJBangMain argument after this PR's changes, so the un-migrated call fails to compile.

Fix: Apply the same migration pattern to the remaining call at line ~596 of ExportDependencyTest.java:

-        Export command = new Export(new CamelJBangMain());
+        Export command = new CamelJBangMain().command(new Export());

This review was generated by an AI agent, Hermès on behalf of @gnodet.

…ort with the no-arg constructor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus

Copy link
Copy Markdown
Contributor Author

Thanks @gnodet-bot, fixed in 859fa7a. That test (shouldAddCamelHealthWhenTheHealthCheckIsOn) came from main with CAMEL-27237 after this stack was cut, so the merge of main brought in a call site the PR had not migrated. It now uses new CamelJBangMain().command(new Export()) like the other two. No other call to the old command constructors is left; camel-jbang-core test-compiles.

Claude Code on behalf of Claus Ibsen

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct. ✅

ExportDependencyTest.java line 596 — the remaining new Export(new CamelJBangMain()) call site has been migrated to new CamelJBangMain().command(new Export()), consistent with the two calls already migrated earlier in the same test file.

No new issues in this commit.

Next step: rebase the branch onto main to drop the now-merged #30374 stacked commits — that will also re-trigger CI.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

The --mask option from CAMEL-27223 goes into the commands without their
CamelJBangMain constructor, and its tests create the commands with
CamelJBangMain.command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous findings are all addressed. ✅

The --mask feature added in this batch of commits is clean across all 11 commands. ListingFormat.masked() delegates correctly to URISupport.sanitizeUri() (Camel's established log-sanitization method), propagation is consistent across every command that displays endpoint URIs, the default of true is the right security posture, and both --mask=false and the edge cases (RAW-encoded passwords, user-info passwords, bracket-notation parameters, null input) are covered by the new unit and integration tests. No issues found.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • docs
  • dsl/camel-jbang/camel-jbang-core
  • dsl/camel-jbang/camel-jbang-mcp
  • dsl/camel-jbang/camel-jbang-plugin-edit
  • dsl/camel-jbang/camel-jbang-plugin-generate
  • dsl/camel-jbang/camel-jbang-plugin-kubernetes
  • dsl/camel-jbang/camel-jbang-plugin-mcp
  • dsl/camel-jbang/camel-jbang-plugin-test
  • dsl/camel-jbang/camel-jbang-plugin-tui
  • dsl/camel-jbang/camel-jbang-plugin-validate
  • dsl/camel-jbang/camel-launcher

🔬 Scalpel shadow comparison — Scalpel: 5 of 728 tested, 0 compile-only — current: 5 all tested

Maveniverse Scalpel detected 5 affected modules (current approach: 5).

Skip-tests mode would test 5 modules (11 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (5)
  • camel-jbang-mcp ← dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/RouteDiagramTools.java, dsl/camel-jbang/camel-jbang-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/VersionTools.java
  • camel-jbang-plugin-mcp ← dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpCommand.java, dsl/camel-jbang/camel-jbang-plugin-mcp/src/main/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpPlugin.java, dsl/camel-jbang/camel-jbang-plugin-mcp/src/test/java/org/apache/camel/dsl/jbang/core/commands/mcp/McpCommandTest.java
  • camel-jbang-plugin-tui ← dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiCommand.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiPlugin.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiWebServer.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitorRecordOptionsTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitorTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorStartupTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorTabRefreshTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorTabTextInputTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/SemanticTabTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiCommandRecordOptionsTest.java, dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiCommandThemeOptionsTest.java
  • camel-jbang-plugin-validate ← dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/PropertiesValidateCommand.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/SourceValidateCommand.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateCommand.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidatePlugin.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeCommand.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlValidateCommand.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateCamelVersionTest.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateJsonTest.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizeKameletTest.java, dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlNormalizePerFileTest.java
  • camel-launcher-container ← depends on affected reactor module org.apache.camel:camel-launcher

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 2 test(s) disabled on GitHub Actions
  • dsl/camel-jbang/camel-jbang-mcp: 2 test(s) disabled on GitHub Actions
  • dsl/camel-jbang/camel-jbang-plugin-kubernetes: 9 test(s) disabled on GitHub Actions
  • dsl/camel-jbang/camel-jbang-plugin-validate: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core, dsl/camel-jbang/camel-jbang-plugin-generate, dsl/camel-jbang/camel-jbang-plugin-edit, dsl/camel-jbang/camel-jbang-plugin-kubernetes, dsl/camel-jbang/camel-jbang-plugin-test, dsl/camel-jbang/camel-launcher. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (14 modules, 3m 54s total)

Total reactor time: 3m 54s

Module Duration Status
Camel :: JBang :: Plugin :: TUI 55.9s SUCCESS
Camel :: JBang :: MCP 46.1s SUCCESS
Camel :: Launcher 43.5s SUCCESS
Camel :: JBang :: Plugin :: Validate 24.0s SUCCESS
Camel :: Docs 17.3s SUCCESS
Camel :: JBang :: Plugin :: Kubernetes 14.0s SUCCESS
Camel :: JBang :: Plugin :: Testing 12.8s SUCCESS
Camel :: JBang :: Plugin :: Generate 8.0s SUCCESS
Camel :: JBang :: Plugin :: MCP 4.1s SUCCESS
Camel :: JBang :: Plugin :: Edit 3.5s SUCCESS
Camel :: JBang :: Integration tests 1.7s SUCCESS
Camel :: JBang :: Main 1.7s SUCCESS
Camel :: Launcher :: Container 1.5s SUCCESS
Camel :: JBang :: Core n/a

Top 20 slowest modules:

  • Camel :: JBang :: Plugin :: TUI (55.9s)
  • Camel :: JBang :: MCP (46.1s)
  • Camel :: Launcher (43.5s)
  • Camel :: JBang :: Plugin :: Validate (24.0s)
  • Camel :: Docs (17.3s)
  • Camel :: JBang :: Plugin :: Kubernetes (14.0s)
  • Camel :: JBang :: Plugin :: Testing (12.8s)
  • Camel :: JBang :: Plugin :: Generate (8.0s)
  • Camel :: JBang :: Plugin :: MCP (4.1s)
  • Camel :: JBang :: Plugin :: Edit (3.5s)
  • Camel :: JBang :: Integration tests (1.7s)
  • Camel :: JBang :: Main (1.7s)
  • Camel :: Launcher :: Container (1.5s)

⚙️ View full build and test results

@oscerd oscerd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large but coherent, and it completes the aesh story started in #30374. The driver is the aesh annotation processor: it generates the command metadata at compile time, which is what lets the runtime class-path scan stay off, and it instantiates commands through a no-arg constructor. That is why every command drops its (CamelJBangMain main) constructor and CamelCommand moves from a final, constructor-injected main to a setCamelMain that CamelJBangMain#command calls right after creating the command, with getMain() throwing IllegalStateException when it was not set.

The per-command change is uniform, just removing the forwarding constructor, so the large file count is mechanical. The one design trade-off is that main is no longer final, but that is forced by the no-arg requirement, and the getMain() guard turns a command created outside the factory into a fast, clear failure instead of an NPE, which is the right mitigation. Since the old constructors only forwarded main to super and initialized nothing from it, the late set does not break any field-initialization assumption.

The pom side is the careful part and the comments earn their place. The processor runs with native-image metadata disabled, and its own generated registry (META-INF/aesh/registry and the MetadataRegistry service file) is deleted after process-classes because it carries the metadata of commands a plugin extends, in the package of whichever command the processor saw first, leaving the CLI's own CommandMetadataRegistry as the single source. That explains a deletion that would otherwise look surprising.

Together with #30374 this is the full picture: compile-time generated metadata, the CLI's own registry, and no runtime scan. Green, with an upgrade-guide note. The surface area is wide, so the CamelJBangMain#command factory wiring is the one spot I would give a second committer read, but the pattern holds. No blockers.

Claude Code on behalf of oscerd

@davsclaus davsclaus self-assigned this Nov 19, 2026
@davsclaus
davsclaus merged commit 61e5965 into main Nov 19, 2026
14 checks passed
@davsclaus
davsclaus deleted the CAMEL-27232-aesh-processor branch November 19, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs dsl enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants