davsclaus opened a new pull request, #29918:
URL: https://github.com/apache/camel/pull/29918

   Item 3 of [CAMEL-26931](https://issues.apache.org/jira/browse/CAMEL-26931).
   
   ## Problem
   
   `PluginAdd` only downloads a plugin when it picks a community release 
itself. So `camel plugin add kubernets` (a typo) prints "Plugin kubernets 
added" and exits 0. After that, every `camel run` and `camel export` fails, 
because `PluginHelper.getActivePlugins` treats an entry without `appliesTo` as 
a contributor to run and export, and a contributor that does not resolve fails 
the command.
   
   On the launcher from main:
   
   ```
   $ camel plugin add kubernets
   Plugin kubernets added                        # exit 0
   $ camel run hello.yaml
   ... ERROR ... Error downloading: 
org.apache.camel:camel-jbang-plugin-kubernets:4.24.0-SNAPSHOT ...
                                                 # exit 1, 63 lines
   ```
   
   ## Change
   
   - **`camel plugin add`** resolves a plugin it does not know before storing 
it: one that is neither a Camel plugin (`PluginType`) nor a known community 
plugin, given without `--gav` or `--artifactId`. It resolves the way the plugin 
is used: from the classpath, or as 
`org.apache.camel:camel-jbang-plugin-<command>`. When it cannot be loaded, the 
command exits 3 with the plugins of a similar name (`SuggestSimilarHelper`), 
and nothing is stored:
   
     ```
     ERROR: Unknown plugin: kubernets. Did you mean: kubernetes. camel plugin 
list shows the plugins; give --gav (or --artifactId) to add a plugin of your own
     ```
   
     A Camel plugin that `PluginType` does not list yet can still be added by 
name, as before, since it resolves.
   - **`PluginHelper.getActivePlugins`** leaves out, with a warning (once per 
plugin), a plugin that only contributes to the command (`camel run`, `camel 
export`) and cannot be loaded, instead of failing the command. This also covers 
entries that earlier versions stored. The plugin's own command still fails.
   
     ```
     WARN: Plugin kubernets cannot be loaded (camel-jbang-plugin-kubernets not 
found), so camel run goes on without it: remove it with camel plugin delete 
kubernets
     ```
   - **Docs:** "Manage plugins" in `camel-jbang-projects.adoc`.
   
   ## Tests
   
   - `PluginAddTest`: a plugin that cannot be loaded is not added (exit 3, "Did 
you mean: kubernetes", the configuration stays empty). The existing tests that 
add a plugin by name still pass, as their plugin resolves.
   - `PluginHelperTest`: a contributor that cannot be resolved does not fail 
`getActivePlugins(..., "run", ...)`, and warns; its own command still fails.
   - End to end with the launcher: main stores `kubernets` and `camel run` 
fails. With the patched jar, `camel run` with that stored entry starts and 
warns, and `camel plugin add kubernets` exits 3 with the one line above.
   - `PluginFilteringTest`: two tests proved that a broken plugin was included 
for export and run by the error it raised. They now check the warning, which 
names the plugin and the command. The warning is printed once per plugin and 
printer, so a command that looks up its plugins twice warns once.
   - camel-jbang-core: 3000 + 259 tests pass (`DependencyUpdateTest` failed 
once and passed on the rerun, as on other branches).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to