Croway opened a new pull request, #27655: URL: https://github.com/apache/camel/pull/27655
## Description [CAMEL-25528](https://issues.apache.org/jira/browse/CAMEL-25528) `camel run` read `camel.jbang.dependencies` (and `camel.jbang.dependencies.main` / `.spring-boot` / `.quarkus`) only from the profile properties: the `application.properties` (and `application-<profile>.properties`) of the current directory or of `--source-dir`. A properties file given on the command line, or with `--properties`, was used for property placeholders only, and the dependencies in it were dropped without any message. So `camel run camel` worked (the directory runs as `--source-dir`), but `camel run camel/*.yaml camel/application.properties` from the same place did not, and beans whose class is not in the known-dependencies tables failed with `ClassNotFoundException`. We hit this repeatedly while evaluating AI coding agents on migrations to Camel: they declare `camel.jbang.dependencies` in `camel/application.properties`, as documented, and run the routes from the project root. Changes: 1. `Run` adds the dependencies of the local properties files given on the command line or with `--properties`, after the ones of `--dep` and of the profile properties. The profile files are not read twice, remote locations (`github:`, `classpath:`...) and missing files are skipped. `camel export` gets them as well, as it reads the dependencies that `Run` writes in its settings. 2. `camel-main-known-dependencies.properties` maps the classes of a transacted route, so they are downloaded on demand: `DataSourceTransactionManager`, `JdbcTransactionManager` and `DriverManagerDataSource` to `camel:sql` (spring-jdbc, which brings spring-tx), `PlatformTransactionManager`, `TransactionTemplate` and `org.apache.camel.spring.spi.SpringTransactionPolicy` to `camel:spring` (spring-tx). Exact class names, like the existing `SimpleDriverDataSource` entry. 3. The user manual says where `camel.jbang.dependencies` is read from. Why honour the keys rather than only warn: the dependency keys are additive and have no other meaning in a properties file, the file was named explicitly by the user, and it makes `camel run camel/*` behave like `camel run camel`. Only the dependency keys are read from these files; the other `camel.jbang.*` settings (download, repositories, versions, ...) keep coming from the profile properties only, as they change how the run itself is set up and a second source would need precedence rules. Note that CAMEL-22673 (dependencies in a non-profile `--properties` file) was closed as not intended to be supported; if you prefer to keep it that way, I can turn the change into a WARN naming the file, the key and the alternatives (`./application.properties`, `--dep`, `//DEPS`) instead. Tests: - `RunPropertiesFilesDependenciesTest` (new): files on the command line and in `--properties`, `file:` and `file://` locations, runtime-specific keys for main, Spring Boot and Quarkus, no duplicates with the profile file, remote and missing files skipped. - `KnownDependenciesResolverTest`: the new mappings resolve to `camel-sql` and `camel-spring` with a version. - Manually, with the CLI built from this branch: `camel run camel/routes.camel.yaml camel/application.properties` and `--properties=camel/application.properties` now start a route with a `JdbcTemplate` bean declared through `camel.jbang.dependencies` in `camel/application.properties` (4.22.0 fails with `ClassNotFoundException`), and `camel export` with the same arguments puts the dependency in the pom. ## Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) ## Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). ## Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [x] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. -- 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]
