davsclaus opened a new pull request, #28126: URL: https://github.com/apache/camel/pull/28126
[CAMEL-25833](https://issues.apache.org/jira/browse/CAMEL-25833): with `camel run --dev`, a dependency added to `camel.jbang.dependencies` in application.properties while the app runs was not downloaded. `camel run` reads the dependencies of the properties files once, and KameletMain downloads them when the app starts (`CommandLineDependencyDownloader`). Since CAMEL-25767 (#28123), a reload creates the new beans of the file, so a bean whose class comes from such a dependency failed: ```properties camel.jbang.dependencies = com.github.javafaker:javafaker:1.0.2 camel.beans.faker = #class:com.github.javafaker.Faker ``` ``` java.lang.ClassNotFoundException: com.github.javafaker.Faker ``` A `//DEPS` line in a source file was downloaded in a reload already: the routes loader parses the modelines on every load. So was a class from one of the 147 packages camel-jbang knows. The gap was a library outside that list, declared in a properties file, which is the place the AI tools of the camel-jbang-mcp server give for such a library. - New `ReloadDependencyDownloader` (camel-kamelet-main): downloads the dependencies in `camel.jbang.dependencies` and `camel.jbang.dependencies.main` of a properties file that changed, resolved as when the app starts (`camel:` shorthands included), unless they are on the classpath. - A library that is on the classpath in another version is not downloaded, as both versions would then be on the classpath. A WARN says that a restart is needed to change the version. - `KameletMain` overrides `autoConfigurationFromReloadedProperties` (protected, from #28123), so the dependencies are downloaded before the beans and components of the reload are created. - Docs: camel-jbang-running.adoc says that this works in dev mode, and that changing the version of a library or removing one needs a restart. ## Tests - New `ReloadDependencyDownloaderTest` (3), with a recording downloader as in `CommandLineDependencyDownloaderTest`: the dependencies of both keys that are not on the classpath are downloaded; a library on the classpath in another version is not, and is returned as needing a restart; properties without dependencies download nothing. - All tests of camel-kamelet-main pass (59, 8 skipped). - End to end, with the camel launcher built from this branch and `camel run --source-dir=. --dev`: - appending the two lines above while the app runs: `Downloading the dependency com.github.javafaker:javafaker:1.0.2 added to camel.jbang.dependencies`, then `Binding bean: faker (type: com.github.javafaker.Faker)`, and the routes reload. Before: `ClassNotFoundException: com.github.javafaker.Faker`, and no bean; - the same lines before the app starts work as before; - javafaker 1.0.1 when the app starts, changed to 1.0.2 while it runs: `The dependency com.github.javafaker:javafaker:1.0.2 in camel.jbang.dependencies is not downloaded, as version 1.0.1 is on the classpath: restart to change the version`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m -- 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]
