CAMEL-23335: camel-jbang - Lazy plugin discovery and resolved-classpath cache#23129
Open
ammachado wants to merge 1 commit into
Open
CAMEL-23335: camel-jbang - Lazy plugin discovery and resolved-classpath cache#23129ammachado wants to merge 1 commit into
ammachado wants to merge 1 commit into
Conversation
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
💡 Manual integration tests recommended:
All tested modules (6 modules)
|
Croway
reviewed
May 12, 2026
Croway
reviewed
May 12, 2026
Croway
reviewed
May 12, 2026
…th cache Two related changes to remove per-invocation plugin overhead from `camel`: * `CamelJBangMain.execute` now consults a new `PluginHelper.shouldDiscoverPlugins` gate before calling `addPlugins`. Built-in commands that do not consume plugins (e.g. `version`, `get`, `ps`, `stop`) short-circuit the plugin JSON read and FACTORY_FINDER classpath scan entirely. Plugin-consuming built-ins (`run`, `export`, `cmd`, `shell`), unknown subcommands (likely plugin-provided), and no-args/help still discover so plugin commands remain visible. * `PluginHelper.resolvePlugin` now reads a `resolved` block from the per-plugin entry in `~/.camel-jbang-plugins.json`. When present and valid (Camel version, gav, repos match; cached jars and the plugin POM unchanged by size+mtime), the plugin is loaded directly from a URLClassLoader over the cached jars, skipping FACTORY_FINDER and the Maven downloader. The resolved block is populated on the first successful Maven resolution; SNAPSHOT plugins rebuilt locally are picked up automatically via the mtime check. Tests cover the gate's classification, cache hit, mtime-based invalidation, the write path, and a paired before/after demonstration of the cache fast path (no resolved block -> resolver invoked and quits; resolved block present -> plugin loaded from the cached jar without invoking the resolver). The existing `testCacheInvalidatedOnMtimeChange` is cleaned up to use `assertThrows` instead of a try/empty-catch block. Upgrade guide updated. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> rh-pre-commit.version: 2.3.2 rh-pre-commit.check-secrets: ENABLED
davsclaus
approved these changes
May 12, 2026
Contributor
|
So I guess this makes this part a little bit faster - especially when you have custom plugins installed like forage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two related changes to remove per-invocation plugin overhead from
camel:CamelJBangMain.executenow consults a newPluginHelper.shouldDiscoverPluginsgate before calling
addPlugins. Built-in commands that do not consume plugins(e.g.
version,get,ps,stop) short-circuit the plugin JSON read andFACTORY_FINDER classpath scan entirely. Plugin-consuming built-ins
(
run,export,cmd,shell), unknown subcommands (likely plugin-provided),and no-args/help still discover so plugin commands remain visible.
PluginHelper.resolvePluginnow reads aresolvedblock from the per-pluginentry in
~/.camel-jbang-plugins.json. When present and valid (Camel version,gav, repos match; cached jars and the plugin POM unchanged by size+mtime), the
plugin is loaded directly from a URLClassLoader over the cached jars, skipping
FACTORY_FINDER and the Maven downloader. The resolved block is populated on
the first successful Maven resolution; SNAPSHOT plugins rebuilt locally are
picked up automatically via the mtime check.
Tests cover the gate's classification, cache hit, mtime-based invalidation, the
write path, and a paired before/after demonstration of the cache fast path
(no resolved block -> resolver invoked and quits; resolved block present ->
plugin loaded from the cached jar without invoking the resolver). The existing
testCacheInvalidatedOnMtimeChangeis cleaned up to useassertThrowsinstead of a try/empty-catch block.
Upgrade guide updated.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.